如何从 3.5 项目后期绑定 CLR 4.0 程序集?
标题是不言自明的我想要完成的任务。我有一个在 3.5 中内置的 COM 可见组件,而我的新项目是 4.0。我想要从 3.5 组件运行的代码与下面的代码非常相似。
Assembly a = Assembly.LoadFrom(@"C:\MyCLR4.exe");
Type t = a.GetType("MyCLR4Class");
object o = Activator.CreateInstance(t);
最终我收到错误“此程序集是由比当前加载的运行时更新的运行时构建的,无法加载”
我对在其他地方发现的情况感到非常沮丧。我所需要的只是一个解决方法来完成此任务。 谢谢!
The title is self-explanatory of what I want to accomplish. I have a COM-visible component built in 3.5 and my new projects are 4.0. Code very similar to the one below is what I want to run from the 3.5 component.
Assembly a = Assembly.LoadFrom(@"C:\MyCLR4.exe");
Type t = a.GetType("MyCLR4Class");
object o = Activator.CreateInstance(t);
Ultimately I'm getting the error "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded"
I'm pretty discouraged by what I've found elsewhere. All I need is a workaround to accomplish this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我放弃。正如托尼·李(Tony Lee)所指出的(感谢链接),如果不对 GAC 和 COM 注册进行一些严重的妥协和各种黑客攻击,这根本无法完成。我最终在 4.0 中重建了一切。
解释一下爱因斯坦:
“.NET 很好,但 Microsoft 一直在拖我们的后腿”
:)
感谢大家的评论和帮助。
I give up. This simply cannot be done without making some serious compromises and various hacks with the GAC and COM registration as pointed out by Tony Lee (thanks for the links). I ended up rebuilding everything in 4.0.
Paraphrasing A. Einstein:
".NET is well and good but Microsoft keeps dragging us around by the nose"
:)
Thank you all for the comments and help.