mercredi 14 octobre 2015

Can EventInfo.GetRaiseMethod return an instance, when used on CIL from VB.NET?

In the thread EventInfo.GetRaiseMethod() always null, there is an answer by well-known expert Hans Passant where he explains that if the CIL comes from VB.NET (or F# or C++/CLI), as opposed to C#, then the method EventInfo.GetRaiseMethod will return something (i.e. an instance, a reference that is not null or Nothing).

Not being very familiar with VB.NET, I tried to write some VB.NET code with an Event, trying to obtain a case such that GetRaiseMethod returns something.

I tried the AddHandler statement, but I tried a Handles clause as well. The former seems to subscribe to the event only at run-time (like in C# with the += operator, I think?), but the latter seems more promising in that it declares the relation at compile-time(?).

Still I had no success with GetRaiseMethod, it returns Nothing (null). How do I create an example to show that GetRaiseMethod can return non-trivially for code that comes from VB.NET?





Aucun commentaire:

Enregistrer un commentaire