允许C#应用程序构建在.NET 2.0到.NET 4.0 / 4.5上运行 [英] Allow C# application built with .NET 2.0 to run on .NET 4.0/4.5
问题描述
我们有一个C#DLL(姑且称之为程序myapp.exe
)建有.NET 2.0框架(VS2005),我们发现,我们的应用程序将无法正常工作的只有.NET 4.0或更高版本的安装位置的机器。为了让在.NET 4.0中我们的应用程序的工作,我添加了按照本文<后续的一些行 myapp.exe.config
href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/08/03/installing-net-framework-v4-0-and-running-net-2-0-3-0-3-5-3-5sp1-applications.aspx">Installing .NET框架V4.0和运行.NET 2.0 / 3.0 / 3.5 / 3.5SP1应用
&LT;启动&GT;
&LT; supportedRuntime版本=v4.0.30319/&GT;
&LT; /启动&GT;
和其工作正常。
然后我看到这篇文章还提到以下(尤其是第二段):
现在,我知道,你不能只取一3.5 Service Pack 1中的应用 并运行它 在V4.0 CLR。它需要一个V2.0 CLR或具有重新配置 标签以弯曲应用在V4.0 CLR运行和弯曲威力 是东西,你不想做的事。
我还没有意识到,虽然那是什么安装.NET 4.0不会安装 你需要一个2.0 / 3.0 / 3.5 / 3.5SP1应用程序位。它只会安装 在V4.0 CLR和V4.0组件和不加装相当于 对.NET框架V3.5 SP1。所以,你需要安装(比如)的.NET Framework V3.5 SP1的 自己与.NET 4.0
这是我的测试中这将意味着我可以在.NET 4.0与.NET 4.0框架(4.0组件/库),这是矛盾的文章说的话我跑2.0 C#应用程序。
还是我失去了一些东西呢?这可能是有益的,如果有人能澄清这一点。微软并没有真正明确这一点的。
这是我的测试中这将意味着我可以使用.NET 4.0框架(4.0组件/库),这是矛盾的文章说的话我跑在.NET 4.0 2.0 C#应用程序。
您的可以的使用.NET 4集在.NET 4运行应用程序。总有可能,有可能是在运行时的行为稍有变化,但是你不会使用它时使用的发展同样运行时和框架。我怀疑这篇文章试图表明,你不会只是安装4.0,不过,因为你所看到的,它应该得到完全相同的行为。
这样做可能是好的,但我会建议做你的应用程序进行彻底的测试,如果这将是一个标准的部署选项。
We have a C# DLL (let's call it myapp.exe
) built with .NET 2.0 Framework (VS2005) and we found out that our application won't work on machines where only .NET 4.0 or above is installed. To let our application work on .NET 4.0, I added the following some lines to myapp.exe.config
by following this article Installing .NET Framework V4.0 and Running .NET 2.0/3.0/3.5/3.5Sp1 Applications
<startup>
<supportedRuntime version="v4.0.30319"/>
</startup>
And it is working.
Then I saw that this article also mentioned the following (especially second paragraph):
Now, I knew that you can’t just take a 3.5 Service Pack 1 application and run it on the V4.0 CLR. It needs a V2.0 CLR or reconfiguring with a tag in order to bend the application to run on the V4.0 CLR and that bending might be something that you don’t want to do.
What I hadn’t realised though was that installing .NET 4.0 wouldn’t install the bits that you need for a 2.0/3.0/3.5/3.5Sp1 application. It would only install the V4.0 CLR and the V4.0 assemblies and not additionally install the equivalent of .NET Framework V3.5 Sp1. So, you’d need to install (e.g.) .NET Framework V3.5 Sp1 yourself along with .NET 4.0
From my testing it would mean that I could run my 2.0 C# application on .NET 4.0 with .NET 4.0 framework (4.0 assembly/libraries) which is contradicting to what the articles said.
Or am I missing something here? It could be helpful if someone could clarify on this. Microsoft doesn't really make this clear at all.
From my testing it would mean that I could run my 2.0 C# application on .NET 4.0 with .NET 4.0 framework (4.0 assembly/libraries) which is contradicting to what the articles said.
You can run your application on .NET 4 using the .NET 4 assemblies. There is always the possibility that there may be a slight change in runtime behavior, however, as you won't be using the same runtime and framework which you used for development. I suspect the article is trying to suggest that you won't get the exact same behavior by just installing 4.0, though, as you've seen, it should work.
Doing this is likely fine, though I would recommend doing thorough testing of your application if this is going to be a standard deployment option.
这篇关于允许C#应用程序构建在.NET 2.0到.NET 4.0 / 4.5上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!