在.NET-4系统仅使用.NET-2.0-针对性COM DLL在GAC [英] Using a .NET-2.0-targeted COM DLL in the GAC on a .NET-4-only system
问题描述
再次问候,
随着我的previous的问题,我想最大限度地发挥我的C#-written Windows资源管理器扩展的兼容性。特别是,我很感兴趣,并确保它的工作原理在其中.NET 4的安装环境和.NET 3.5及以下的没有的安装。人们可能会认为没有任何问题,但显然它不是那么简单......
Following up my previous question, I'm trying to maximize the compatibility of my C#-written Windows Explorer extension. In particular, I'm interested in making sure it works in an environment in which .NET 4 is installed and .NET 3.5 and below are not installed. One would think there's no problem, but apparently it's not so simple...
有两个问题。首先,非.NET-4定位组件平出的不会负载CLR 4,除非他们有一个的.config
文件,指定< supportedRuntime版本=V4.0/>
。甚至试图用 NGEN
他们将会失败没有这个的.config
文件。但我的DLL云在GAC。在我如何获得的.config
文件存在吗?其他人都问同样的事情,并得出结论好了,我就做一个静态的设置类代替。很显然,我不能这样做......
There are two problems. First, non-.NET-4-targeted assemblies flat out will not load with CLR 4 unless they have a .config
file that specifies <supportedRuntime version="v4.0" />
. Even trying to use ngen
on them will fail without this .config
file. But my DLL goes in the GAC. How do I get a .config
file in there too? Others have asked the same thing, and reached the conclusion "well, I'll just make a static Settings class instead." Obviously I can't do that...
第二个问题:当我登记我的DLL与 regasm.exe
,然后打开注册表,看看它写的,我看 RuntimeVersion = V2.0.50727
根据其CLSID项。这也prevents加载的DLL。只有当我手动更改 RuntimeVersion
值 v4.0.30319
做的DLL加载。
Second problem: When I register my DLL with regasm.exe
, and then open up the registry to see what it wrote, I see RuntimeVersion = v2.0.50727
under its CLSID entry. This also prevents the DLL from loading. Only after I manually change the RuntimeVersion
value to v4.0.30319
does the DLL load.
那么到底什么我必须让我的安装程序在这里做?这是第一个我不知道。对于第二个,我想我必须已经安装手动设置注册表的RuntimeVersion到任何.NET版本安装?这似乎太古怪的是真实的......
So what the heck do I have to make my installer do here? For the first one I have no idea. For the second, I guess I have to have the installer set the registry's RuntimeVersion manually to whatever .NET version is installed? That seems too wacky to be true...
推荐答案
NET 2.0 - 3.5和.NET 4.0中有两种不同的GAC的,如果我没有记错
.Net 2.0 - 3.5 and .Net 4.0 has two different GAC's, if I recall correctly.
的大小问题,部分解决了.NET 4的安装(86 + 64)为54 MB,而不是嵌入的previous版本完整的运行安装包。 - http://en.wikipedia.org/wiki/.NET_Framework
"The size issue is partially solved with .NET 4 installer (x86 + x64) being 54 MB and not embedding full runtime installation packages for previous versions." - http://en.wikipedia.org/wiki/.NET_Framework
所以,如果你安装.Net 3.5,您将获得previous的.Net运行时。这可能会造成混乱与.NET 4.0,其中不包括这些previous运行时间。我认为,这意味着你需要安装.Net 3.5运行时沿端.NET 4.0中得到&LT; = 3.5的.Net运行时安装到GAC
So if you install .Net 3.5, you get the previous .Net runtimes. This might be confusing with .NET 4.0, which does not include these previous runtimes. I believe this means you need to install .Net 3.5 runtime along-side .Net 4.0 to get <= .Net 3.5 runtimes to install into the GAC.
我也相信,如果你改变了RuntimeVersion,你所得到的.DLL安装到了错误的GAC。她有兴趣,但是,如果这样做的工作。我不相信它在实时环境中,但它会确实很有意思。
I also believe if you change the RuntimeVersion, you are getting the .DLL to install into the wrong GAC. It would be interesting, however, if this does work. I wouldn't trust it in a real-time environment, but it would be very interesting indeed.
这篇关于在.NET-4系统仅使用.NET-2.0-针对性COM DLL在GAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!