2009-05-22 41 views
7

可以說我有一箇舊的應用程序將嘗試加載外部程序集。如何運行CLR 2應用程序作爲CLR 4應用程序

  • 舊的應用程序被編譯爲CLR 2
  • 新組件被編譯爲CLR 4

我想能夠運行內部CLR 4.我記得舊的應用程序有一些涉及xml manifest magic

如何創建該清單xml文件來告訴oldapplication.exe應該在CLR 4下運行?

我發現了一些建議,但它們似乎不適合我。

oldapplication.exe.config:

<?xml version ="1.0"?> 
<configuration> 
<startup> 
     <!--set the appropriate .net version--> 
     <requiredRuntime version="4.0.0.0"/> 
</startup> 
</configuration> 

同時給予再出手,我發現這個文件作爲我的TEMPL吃:

C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.20506 \ Aspnet_regsql.exe.config

<?xml version ="1.0"?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0.20506"/> 
     <requiredRuntime version="v4.0.20506" safemode="true"/> 
    </startup> 
</configuration> 

我也更新了代碼報告當前CLR:

Console.WriteLine(typeof(object).Assembly.ImageRuntimeVersion); 

它現在有效!

+1

+1。也只是要問這個問題,因爲我真的需要.NET 4的64位JIT來支持正確的尾部呼叫。 – leppie 2011-05-12 10:42:12

回答

7

您需要提供正確的版本號。請注意,這是測試版本1,它將改變直到RTM落戶之一:

<configuration> 
<startup> 
     <supportRuntime version="4.0.20506"/> 
</startup> 
</configuration> 
1

我相信你想使用supportedRuntime,而不是requiredRuntime。

「<supportedDuntime>元素應該由使用版本1.1或更高版本的運行時構建的所有應用程序使用。」 (http://msdn.microsoft.com/en-us/library/a5dzwzc9.aspx)。確保版本字符串與所需版本的「安裝文件夾名稱」完全匹配。

1

爲鄉親在2013+

配置文件吉斯特發現通過谷歌這個網頁
https://gist.github.com/1223509

博客文章
http://yzorgsoft.blogspot.com/2011/09/greenshot-on-windows-8-net-45.html

<?xml version ="1.0"?> 
<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0.30319" /> 
    <requiredRuntime version="v4.0.30319" safemode="true"/> 
    </startup> 
    <runtime> 
    <relativeBindForResources enabled="true" /> 
    <UseSmallInternalThreadStacks enabled="true" /> 
    <DisableMSIPeek enabled="true"/> 
    </runtime> 
</configuration> 

該配置文件是從Visual Studio 2012中提取的,因此它具有一些額外的COM兼容性和性能調整。對於運行託管代碼的環境,您應該刪除<runtime>部分。

相關問題