I am trying to generate and assign to that delegate based on a method in the existing code. The project compiles without errors.
The delegate is generated correct (as far As I can see) - decompiled code:
Note that I can not find the definition of the Delegate type in the decompiled code.
Then I want to set this delegate.
The code I want is:
ExitApplication_Delegate = AddressOf(ExitApplication)
Decompiled, this looks like:
ExitApplication_Delegate = New CloseAppDelegate(AddressOf Me.ExitApplication)
But the code that is generated is (decompiled):
ExitApplication_Delegate = New ExitApplicationDelegate(Me, ExitApplication)
The generated code is thus using another constructor than written code, and fails on runtime with error
Could not load type 'ExitApplicationDelegate because it cannot inherit directly from the delegate class
The code I use to generate the addressOf code is:
new ProcPtrValue(new SelfValue, "ExitApplication")
What am I doing wrong?