|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can I tell (from C# code) if a .DLL is native or a .NET assembHi,
How can I tell (from C# code) whether a .DLL contains native code or is infact a .NET assembly? I know that I could use Assembly.LoadFile() and see if it throws a BadImageFormatException but I really don't want any exceptions in my normal program flow... sincerely, martin Hello, martin!
m> How can I tell (from C# code) whether a .DLL contains native code or is m> infact a .NET assembly? m> I know that I could use Assembly.LoadFile() and see if it throws a m> BadImageFormatException but I really don't want any exceptions in my m> normal program flow... You will have to analyze file PE format ( http://www.samspublishing.com/articles/article.asp?p=25350&rl=1 ) links in the article are broken, here valid ones ( http://msdn.microsoft.com/msdnmag/issues/02/02/PE/ ) Here is the sample how to do this ( http://geekswithblogs.net/rupreet/archive/2005/11/02/58873.aspx ) One more way to check PE for managed code is "COM Descriptor Directory"
section. If it contains non zero value - file contains managed code Show quoteHide quote "Vadym Stetsyak" wrote: > Hello, martin! > > m> How can I tell (from C# code) whether a .DLL contains native code or is > m> infact a .NET assembly? > > m> I know that I could use Assembly.LoadFile() and see if it throws a > m> BadImageFormatException but I really don't want any exceptions in my > m> normal program flow... > > You will have to analyze file PE format > ( http://www.samspublishing.com/articles/article.asp?p=25350&rl=1 ) > links in the article are broken, here valid ones > ( http://msdn.microsoft.com/msdnmag/issues/02/02/PE/ ) > > Here is the sample how to do this > ( http://geekswithblogs.net/rupreet/archive/2005/11/02/58873.aspx ) > -- > Regards, Vadym Stetsyak > www: http://vadmyst.blogspot -- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche > I know that I could use Assembly.LoadFile() and see if it throws a That's why you catch it.> BadImageFormatException but I really don't want any exceptions in my normal > program flow... And yet that's the only way to be sure. You can reinvent the wheel, but it wouldn't be as good/accurate/fast as Microsoft's, and it may need to be updated in the (unlikely?) event that new DLL formats are created. Microsoft gave you a tool, use it.
lists of generics
Casting a string to a double Repeating a character X number of times? Cursor Position in KeyPressEvent Using multiple windows forms No Symbols Loaded error in C# DataGridViewComboBoxColumn problem What does the syntax"~[Class name]" mean? regex high cpu utilization No Symbols loaded error - C# |
|||||||||||||||||||||||