無法加載混淆程序集 (Cannot load obfuscated assembly)


問題描述

無法加載混淆程序集 (Cannot load obfuscated assembly)

我是第一次使用 dotfuscator。我的項目是用 C# 和 .NET 3.5 編寫的,它有一個主程序和一些插件;這是加載插件的代碼片段:

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

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

現在的問題是:如果我不混淆一切都很好,但是當我使用 dotfuscator asm.GetTypes() 時會拋出一個 ReflectionTypeLoadException,上面寫著

找到的程序集的清單定義與程序集引用不匹配。(來自 HRESULT 的異常:0x80131040)

我用谷歌搜索了幾個小時沒有結果。提前致謝。

編輯:經過一些研究和調試,我認為這是清單中的問題,因為反射無法看到(或加載)程序集中的類型. 我用 Reflector 打開了混淆程序集,但一切似乎都很好。


參考解法

方法 1:

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.

方法 2:

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.

方法 3:

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

(by FabrizioJoe KuemerleCharlie SaltsJosh Smeaton)

參考文件

  1. Cannot load obfuscated assembly (CC BY‑SA 3.0/4.0)

#dotfuscator #load #assemblies #reflection #.net






相關問題

如何在構建中自動化 Dotfuscator (How to automate Dotfuscator in build)

Dotfuscator 命令行 (Dotfuscator command line)

Dotfuscator có vẻ như không tuân theo việc đổi tên RegEx (Dotfuscator Seems Not Adhering To Renaming Exclusion RegEx)

如何使用 dotfuscator 合併多個本地化文件? (How can I use dotfuscator to merge multiple localization files?)

在混淆的 Windows 應用商店應用程序中,包含公共調試符號是否有任何危險? (In an obfuscated Windows Store App, is there any danger in including the Public Debug Symbols?)

無法加載混淆程序集 (Cannot load obfuscated assembly)

混淆 .NET Microsoft Office 插件的工具 (Tools that Obfuscate .NET Microsoft Office Add-in)

Dotfuscator 社區版 (Dotfuscator community edition)

Dotfuscator 構建後事件退出,代碼 1 (Dotfuscator Post-Build Event Exited With Code 1)

如何防止重命名所有類,dotfuscator 中的接口 (How to prevent renaming of all classes, interface in dotfuscator)







留言討論