使用AssemblyBuilder,如何将所有或任何引用的程序集嵌入而不是链接到保存的程序集中?
我有一个执行程序集,它使用 AssemblyBuilder 动态生成另一个程序集。
生成的程序集由一些函数组成,这些函数只是测试执行程序集中某些类的构造。 由于生成的程序集中的函数引用执行程序集中的类,因此我希望执行程序集将自身嵌入到它创建的程序集中。
到目前为止,我只生成了一个链接到执行程序集的程序集,但没有生成嵌入它的程序集。 重要的是我只有一个最终程序集 (.dll)。
我需要将程序集作为资源嵌入吗? 如果是这样,怎么办? 我不想编写代码来动态加载嵌入式程序集,除非这是唯一的方法。 我正在寻找像 AssemblyBuilder.EmbedAssembly( GetExecutingAssembly() ) 这样简单的东西。
I have an executing assembly, which generates another assembly dynamically using AssemblyBuilder.
The generated assembly consists of functions which simply test the construction of certain classes in the executing assembly. Since the functions in the generated assembly reference classes in the executing assembly, I want to have the executing assembly embed itself in the assembly it creates.
So far, I've only managed to generate an assembly that links to the executing assembly, but not one that embeds it. It's important that I have just one final assembly (.dll).
Do I need to embed the assembly as a resource? If so, how? I don't want to have to write code to load the embedded assembly dynamically, unless that's the only way. I'm looking for something easy like AssemblyBuilder.EmbedAssembly( GetExecutingAssembly() ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有简单的方法。 您至少有两个选择:
There's no easy way. You have at least two choices: