dspace-group / dscom

dscom, a toolkit for creating and registering type libraries (tlb) and additional interop helper methods for COM
Apache License 2.0
84 stars 19 forks source link

Enclosing Type(s) not found #314

Open Delucion opened 6 days ago

Delucion commented 6 days ago

After today's Visual Studio update, the dll I make as part of the tlb export process no longer works for exporting. Got the following error:

Failed to export type library. Enclosing type(s) not found for type '?????????????????????????????????????????' in assembly '[dll], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[token]'.

The ?'s are no exaggeration. How would I go about diagnosing this? I'm using the latest version of dscom32, with the command tlbexport.

Any insight would be much appreciated - thank you.

marklechtermann commented 5 days ago

That is very strange!

You can try ILSpy to look into your DLL. https://github.com/icsharpcode/ILSpy

If that doesn't help you have to start dscom in the debugger and see where the exception is thrown.

Delucion commented 5 days ago

Thank you for the help with it. I have the source code for the dll, so do I need to use ILSpy? The strange name of the type may have to do with the fact that the file is obfuscated at build time, which scrambles the names. Even so, it has always worked with tlbexport before.

As for starting it in the debugger, I'm a little confused. I was able to start it in the command line, then use VS to Debug>attach to an existing process (cmd.exe), but I don't understand how to view the output, or if this is the right method at all. Dscom32.exe itself just shuts off when I try to run it from Explorer. Do you have a quick explanation for how to start dscom32 in the debugger? Could save me some time. Thanks so much

marklechtermann commented 1 day ago

DSCOM uses reflection to create a TLB. Depending on how your obfuscator works, this could lead to problems. But this is just a guess.

You can debug DSCOM very easily. For VisualStudioCode we have a launch.json that covers some scenarios.

But it should also be easy in VisualStudio: