【发布时间】:2013-01-15 09:06:56
【问题描述】:
假设我有一个旧应用程序会尝试加载外部程序集。
- 旧应用程序编译为 CLR 2。
- 新程序集编译为 CLR 4。
我希望能够在 CLR 4 中运行那个旧应用程序。我记得其中涉及到一些 xml manifest magic。
如何创建该清单 xml 文件以告知 oldapplication.exe 应在 CLR 4 下运行?
我找到了一些建议,但它们似乎对我不起作用。
- http://www.mibuso.com/forum/viewtopic.php?f=23&t=33840&view=next
- http://geekswithblogs.net/technetbytes/archive/2007/06/01/112928.aspx
- http://msdn.microsoft.com/en-us/library/a5dzwzc9.aspx
oldapplication.exe.config:
<?xml version ="1.0"?>
<configuration>
<startup>
<!--set the appropriate .net version-->
<requiredRuntime version="4.0.0.0"/>
</startup>
</configuration>
在再试一次的时候,我发现这个文件可以作为我的模板:
C:\Windows\Microsoft.NET\Framework\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。我也想问这个,因为我真的需要 .NET 4 的 64 位 JIT 来获得适当的尾调用支持。