简体   繁体   English

以编程方式安装CLR 2.0和CLR 4.0的程序集

[英]Installing assemblies for CLR 2.0 and CLR 4.0 programmatically

I have application, let's name it Installer, that installs my assemblies in GAC using Publish.GacInstall Method. 我有应用程序,我们将它命名为Installer,它使用Publish.GacInstall方法在GAC中安装我的程序集。

I faced an issue when the Insteller is run under .Net 4.0 and installs assemblies in GAC for .Net 4.0. 当Insteller在.Net 4.0下运行并在GAC中为.Net 4.0安装程序集时,我遇到了一个问题。 When I target .Net framework 2.0 for a project I don't see my assemblies in GAC. 当我为项目定位.Net framework 2.0时,我没有在GAC中看到我的程序集。

Is it possible to install my assemblies in both GACs? 是否可以在两个GAC中安装我的程序集?

No, it does not depend on your installer, but on the assemblies it installs. 不,它不依赖于您的安装程序,而是依赖于它安装的程序集。 CLR v4 (.Net 4.0 - 4.5.1) assemblies go in the v4 GAC and CLR v2 (.Net 2.0 - 3.5) assemblies go in the v2 GAC. CLR v4(.Net 4.0 - 4.5.1)程序集在v4 GAC和CLR v2(.Net 2.0 - 3.5)程序集中进入v2 GAC。 If you want an assembly in both, then you have to have two assemblies for each CLR version. 如果您想在两者中都有一个程序集,那么每个CLR版本必须有两个程序集。

Since CLR v4 can run CLR v2 applications you can also do with just the CLR v4 assembly. 由于CLR v4可以运行CLR v2应用程序,因此您也可以只使用CLR v4程序集。 You need change/add a config file with your application. 您需要在应用程序中更改/添加配置文件。 See here . 看到这里

<supportedRuntime version="v2.0.50727"/> 
<supportedRuntime version="v4.0"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM