B
Bob Altman
Hi all,
I need to be able to tell if a DLL is native or managed. The approach most
commonly suggested seems to be to simply try to load the DLL as an assembly
and to catch the appropriate exception if it's not a valid assembly. The
problem with this approach (in my application) is that it winds up
write-locking the DLL. True, I could load the DLL into a different
AppDomain than my main application and then nuke that AppDomain after I've
done my "is it managed" detection, but that's a pain to implement.
Is there some data in the file header that I could look at to determine if
the DLL contains managed code? I have existing code that calls the Windows
MapAndLoad function and digs through the image header for other information
(specifically, the image subsystem to see if it's a GUI application), so if
there is something in the image header that is unique to managed DLLs then I
could easily enough dig that out as well.
TIA - Bob
I need to be able to tell if a DLL is native or managed. The approach most
commonly suggested seems to be to simply try to load the DLL as an assembly
and to catch the appropriate exception if it's not a valid assembly. The
problem with this approach (in my application) is that it winds up
write-locking the DLL. True, I could load the DLL into a different
AppDomain than my main application and then nuke that AppDomain after I've
done my "is it managed" detection, but that's a pain to implement.
Is there some data in the file header that I could look at to determine if
the DLL contains managed code? I have existing code that calls the Windows
MapAndLoad function and digs through the image header for other information
(specifically, the image subsystem to see if it's a GUI application), so if
there is something in the image header that is unique to managed DLLs then I
could easily enough dig that out as well.
TIA - Bob