如何在没有程序集清单的情况下加载.net模块 [英] How to load a .net module without the assembly manifest

查看:67
本文介绍了如何在没有程序集清单的情况下加载.net模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不需要清单的情况下加载.net模块(只是一个正常的程序集,除了它不包含程序集清单)?我有一些程序集在尝试运行它们时抛出此错误:

How can I load a .net module(just a normal assembly except it doesn't contain assembly manifest) without the need of the manifest? I have some assemblies that throws this error when I try to run them:

The module was expected to contain an assembly manifest

通常,我可以通过在添加程序集清单后使用ilasm重新编译程序集来解决此问题:

Normally I can fix this problem by recompiling the assembly using ilasm after adding the assembly manifest:

.assembly test{  }

但是还有其他解决方法来解决此问题吗? Assembly.LoadModule(...)可以解决我的问题吗?

But is there other work around for this problem? Can Assembly.LoadModule(...) fix my problem?

推荐答案

清单是逻辑程序集的一部分,其中可能包含许多文件.而且其中只有一个包含程序集清单(其中有指向所有其他程序集文件的链接),因此您可以进行try-catch块并仅成功装载主程序集模块.

Manifest is a part of an logical assembly which may consist of many files. And only single of them contains assembly manifest(where are links to all other assembly files), so you can make try-catch block and load successfully only the main assembly modules.

这篇关于如何在没有程序集清单的情况下加载.net模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆