Theo69
(Theo)
April 20, 2021, 4:53pm
1
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?
mh
(marc hoffman)
April 20, 2021, 4:54pm
2
can I see this in a project?
Theo69
(Theo)
April 20, 2021, 5:10pm
3
It’s a little bit big …
Theo69
(Theo)
April 20, 2021, 5:43pm
4
Solution to reproduce: ClassLibrary6 1.bugreport.zip (1.6 MB)
Build log (succeeded): ClassLibrary6 1.bugreport.txt (62.2 KB)
Print screen of written code:
Print screen of decompiled code of Class1 in ClassLibrary6 (to VB code):
Print screen of decompiled code of Class1 in ClassLibrary6 (to IL):
In this decompiled code, Example is what was written in code and Test is what was generated.
What I see is:
For Test, the Public Delegate Sub TestDelegate is missing from the code, while it is used (second line of the class).
The generated assignment in the constructor is different than the written assignent for Example.
Edit: When I look at the IL, the only difference I see is that the TestDelegate isn’t defined, but somehow it is used.
mh
(marc hoffman)
April 20, 2021, 6:03pm
5
let me rephrase that: can you illustrate that in a simple project, rather than me having to try and do that based on the code snippets
Theo69
(Theo)
April 20, 2021, 6:04pm
6
Already did. see the post above yours.
1 Like
Theo69
(Theo)
April 22, 2021, 12:12pm
7
Were you able to reproduce? (As it is not marked as a bug)
mh
(marc hoffman)
April 22, 2021, 12:39pm
8
Weird, I could have sworn I had logged this yesterday…
1 Like
Thanks, logged as bugs://85845
Theo69
(Theo)
April 22, 2021, 1:17pm
11
In my decompiler it isn’t in the IL.
And when you instantiate the class, it will crash with a typeload exception on the line Test_Delegate = Test
mh
(marc hoffman)
April 22, 2021, 1:19pm
12
Well, in mine it is, so it has to be there
I cant run this, as its a class library project.
peverify shows errors:
âžś Cherry:~/Downloads/ClassLibrary6 2/Bin/Debug # peverify ClassLibrary6.dll
âžś Cherry:~/Downloads/ClassLibrary6 2/Bin/Debug #
here’s my dll: ClassLibrary6.dll.zip (4.5 KB)
all I did was open your project and build it, no changes.
mh
(marc hoffman)
April 22, 2021, 1:21pm
13
I added
Public Shared Sub Main
New Class1
writeLn(1)
End Sub
and made it an exe. runs fine:
ClassLibrary6 2.zip (1.6 MB)
this is with shipped 2621, but I doubt this got broken, post?
Theo69
(Theo)
April 22, 2021, 1:32pm
14
It doesn’t work in:
So, I am upgrading now and test again.
1 Like
wuping
(wuping)
April 22, 2021, 2:00pm
15
“This is the Water and this is the Well. Drink full and descend” - what interesting poem.
@mh - a fan of Twin Peaks? Reminds me of the move “Get Out (2017)” too.
Theo69
(Theo)
April 22, 2021, 2:02pm
16
Indeed - problem is solved - my apologies.
1 Like
bugs://85845 got closed with status fixed.