本文介绍了如何运行CLR 2应用程序作为CLR 4应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说,我有一个旧的应用程序,它会试图加载外部组件。

  • 在旧的应用程序被编译为CLR 2。
  • 新的组件编译为CLR 4。

我希望能够运行老应用程序内部CLR 4。我记得有一些的的参与。

我怎样才能创建清单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版本=1.0&GT?;
<结构>
 <启动>
      <! - 设置相应的.NET版本 - >
      < requiredRuntime版本=4.0.0.0/>
 < /启动>
< /结构>
 


同时给予再出手,我发现这个文件,以作为我的模板:

 < XML版本=1.0&GT?;
<结构>
    <启动>
        < supportedRuntime版本=v4.0.20506/>
        < requiredRuntime版本=v4.0.20506安全模式=真/>
    < /启动>
< /结构>
 

我还更新了code至报告当前CLR:

  Console.WriteLine(typeof运算(对象).Assembly.ImageRuntimeVersion);
 

它的工作原理吧!

解决方案

您需要提供正确的版本号。请注意,这是公测版本1,它会改变,直到RTM落户之一:

 <结构>
 <启动>
      < supportRuntime版本=4.0.20506/>
 < /启动>
< /结构>
 

Lets say I have an old application which will try to load an external assembly.

  • The old application is compiled to CLR 2.
  • The new assembly is compiled to CLR 4.

I would like to be able to run that old application inside CLR 4. I remember there was some xml manifest magic involved.

How can I create that manifest xml file to tell that oldapplication.exe shall run under CLR 4?

I found some suggestions, but they do not seem to work for me.

oldapplication.exe.config:

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


While giving another shot i found this file to serve as my template:

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

I also updated the code to report current CLR:

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

It works now!

解决方案

You need to give the proper version number. Note that this is the beta 1 version, it will change until RTM settles one:

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

这篇关于如何运行CLR 2应用程序作为CLR 4应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:40