开发者

Cannot load obfuscated assembly

开发者 https://www.devze.com 2023-01-28 14:45 出处:网络
I\'m working for the first time with dotfuscator. My project is written in C# and .NET 3.5, it has a main program and some plugins; this is the slice of code that loads the plugins:

I'm working for the first time with dotfuscator. My project is written in C# and .NET 3.5, it has a main program and some plugins; this is the slice of code that loads the plugins:

// Load the file
Assembly asm = Assembly.LoadFile( pluginPath );

// Instantiate the types I need
foreach( Type type in asm.GetTypes() )
{
    ...
}

Now the problem is: if i don't obfuscate everything is fine but when i use dotfuscator asm.GetTypes() throw a ReflectionTypeLoadException which says

The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I googled for hours with no result. Thanks in advance.

EDIT: After some researches and debugging I think it's a problem in the 开发者_StackOverflow中文版manifest, because the reflection can't see (or loads) the types inside the assembly. I opened the obfuscated assembly with Reflector but everything seems fine.


Are your assemblies strong named or Authenticode signed? Obfuscation changes the structure of the assemblies and in order to use them after obfuscation you need to resign them.

The commercial versions of Dotfuscator supports the resigning of assemblies (both strong name and Authenticode) while if you are using the free Community Edition you will need to resign as a post build step in Dotfuscator.


Obfuscation works, in part, by renaming some or all method names, type names, etc.

Reflection can often fail when obfuscation is used. If you're lucky, you can be selective when it comes to choosing what to obfuscate, but this requires some attention to detail.


I don't think Obfuscation works well with reflection. In fact, I think that's the number one trade off when using obfuscation.

See this link for how to overcome types that need to be reflected over

0

精彩评论

暂无评论...
验证码 换一张
取 消