如何引用a.Net 4.0 COM在.NET 2.0应用程序 [英] How to reference a.Net 4.0 COM in a .Net 2.0 App

查看:218
本文介绍了如何引用a.Net 4.0 COM在.NET 2.0应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,使用DOTNET的4.0 DLL在DOTNET的2.0应用程序,谷歌搜索的问题表现出了<一href="http://stackoverflow.com/questions/2382927/can-i-use-a-net-4-0-library-in-a-net-2-0-application">single合适的解决方案:COM

I had a Problem to use DotNet 4.0 DLL in a DotNet 2.0 Application, googling the Issue showed a single suitable solution: COM

无论如何,我想现在要做到这一点,但我不断收到以下错误,当我添加引用我的应用程序(引用是 TLB ):

Anyway i'm trying to do that now but i keep getting the following Error when i add the reference in my application (the reference is tlb):

该ActiveX类型库MyLib.tlb'是从一个.NET程序集出口   并且不能被添加作为参考。请直接引用了大会。

The ActiveX type library 'MyLib.tlb' was exported from a .NET assembly and cannot be added as a reference. please reference the Assembly directly.

我缺少什么?它说了很多这个选项应该工作的网站: <一href="http://blogs.microsoft.co.il/blogs/arik/archive/2011/05/30/how-to-use-a-net-4-based-dll-from-net-2-based-application.aspx"相对=nofollow>例1 ,例2

Am i missing anything? its stated on a lot of websites that this option should work: Example1, Example2

在另一方面它表示在一个<一个href="http://connect.microsoft.com/VisualStudio/feedback/details/120882/reference-a-com-from-visual-2005"相对=nofollow>微软的旧的链接中,该选项是不可能的按设计

On the other hand its stated on an old link of microsoft that this option is not possible "By Design"

任何想法?提示?

首页我不是混乱的事情。

Home i'm not confusing things.

感谢你。

推荐答案

由于它会导致加载.NET4运行在该.NET2运行时已经加载的过程 - 这是不可能的设计! 支持混合.NET版本在一个过程中引入了.NET 4。

Because it would lead to loading the .NET4 runtime in a process where the .NET2 runtime is already loaded - this is not possible by design! Support for mixing .NET versions in one process was introduced in .NET 4 .

如果你真的需要,使这项工作:

IF you really need to make this work:

  • 请其采用了原生出来的进程COM服务器.NET4 DLL
  • 然后使用该服务器从.NET2过程中(不是直接的.NET4 DLL!)

备注 - 看到有关EF4您的评论后:

REMARK - after seeing your comment about EF4:

我强烈建议你.NET2应用程序转换到.NET 4 - !什么都将是一个真正修的噩梦

I strongly recommend to convert your .NET2 application to .NET 4 - anything else will be a real maintainance nightmare!

这篇关于如何引用a.Net 4.0 COM在.NET 2.0应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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