简体   繁体   English

将.NET配置为在Windows 7和Windows 8上使用3.5和4.5

[英]Configure .NET to use 3.5 on Windows 7 and 4.5 on Windows 8

How can I configure my application to run on both Windows 7 and Windows 8? 如何配置我的应用程序以在Windows 7和Windows 8上运行? My application is written in .net 3.5 and it is working fine in windows 7 but for windows 8 the application is asking to turn on .net 3.5 feature. 我的应用程序是用.net 3.5编写的,并且在Windows 7中工作正常,但是对于Windows 8,应用程序要求打开.net 3.5功能。 This is because Windows8 has .net framework 4.5 by default. 这是因为Windows8默认具有.net Framework 4.5。 So my question is how can I configure my application to use .net 4.5 in Windows 8 and .net 3.5 in windows 7? 所以我的问题是如何配置我的应用程序以在Windows 8中使用.net 4.5,在Windows 7中使用.net 3.5?

Thanks, 谢谢,

You can't 你不能
Your application must target one .NET framework, you can't target several framework. 您的应用程序必须针对一个.NET框架,您不能针对多个框架。 I would suggest you to target .NET 4 because it's widely installed on windows 7, Windows 8 with 4.5 can run app build for .NET 4. And upgrading from .NET 3.5 to .NET 4 works fine. 我建议您以.NET 4为目标,因为它广泛安装在Windows 7上,带有4.5的Windows 8可以运行.NET 4的应用程序构建,并且从.NET 3.5升级到.NET 4效果很好。

Just be sure to target .NET 4 Client Profile because the full .NET 4 is not installed by default on windows computer. 只需确保以.NET 4 客户端配置文件为目标,因为Windows计算机上默认未安装完整的.NET 4。

EDIT: More info on upgrading your code from .NET 3.5 to .NET 4 (I just had to do it a few weeks ago so I know what kind of problem could happend). 编辑:有关将代码从.NET 3.5升级到.NET 4的更多信息(我只是在几周前才这样做,所以我知道会发生什么问题)。
It'll be EASY to do it unless your code use server side components (ie System.Web) which are NOT included in the .NET 4 Client Profile and require the full .NET 4 (not installed by default on end-user win7 PC). 除非您的代码使用服务器端组件(即System.Web),这些组件不包括在.NET 4客户端配置文件中,并且需要完整的.NET 4(默认情况下未在最终用户win7 PC上安装), 否则这样做会很容易。 )。
Just switch your project to .NET 4 Client profile and check if it's compile. 只需将项目切换到.NET 4客户端配置文件,然后检查其是否已编译。 If it's compile it means it doesn't use any server side component. 如果可以编译,则表示它不使用任何服务器端组件。

Follow this link: 点击此链接:

http://www.techrepublic.com/blog/10things/10-things-to-try-when-applications-wont-work-with-windows-8/3540 http://www.techrepublic.com/blog/10things/10-things-to-try-when-applications-wont-work-with-windows-8/3540

Refer : 参考:

Install .NET Framework 3.5 安装.NET Framework 3.5

When you install Windows 8, version 4.5 of the .NET Framework is installed by default. 当您安装Windows 8时,默认情况下会安装.NET Framework 4.5版。 However, older apps often require an earlier version of the .NET Framework. 但是,较旧的应用程序通常需要.NET Framework的早期版本。 If you receive a .NET Framework-related error, you can go into the Control Panel, click on Programs, and choose the option to turn a Windows feature on or off. 如果收到与.NET Framework相关的错误,则可以进入“控制面板”,单击“程序”,然后选择打开或关闭Windows功能的选项。 Windows will display a list of the various components you can enable or disable. Windows将显示可以启用或禁用的各种组件的列表。 One of the items on the list is .NET Framework 3.5, which also includes .NET 3.0 and 2.0. 列表中的一项是.NET Framework 3.5,其中还包括.NET 3.0和2.0。 Installing this component will likely correct the issue that you are experiencing. 安装此组件可能会纠正您遇到的问题。

In that. 在那里面。

Possible things could be: 可能的情况可能是:

  • Compile different assemblies 编译不同的程序集
  • Let the Windows 8 Users install .NET 3.5 (Or the Windows 7 install 4.5) 让Windows 8用户安装.NET 3.5(或Windows 7安装4.5)

The best solution would probably build it in 3.5 and just let the Windows 8 Users install .NET 3.5, they probably need it anyway for more applications. 最好的解决方案可能是将其构建在3.5中,并且仅让Windows 8用户安装.NET 3.5,他们可能仍然需要更多的应用程序。 There is no such thing that the program decides using .NET 4.0 or .NET 3.5 when its started. 程序启动时没有决定使用.NET 4.0或.NET 3.5的事情。 (Or you make some sort of dropper that it compiles the binary with codedom at runtime.) (或者,您可以制作某种类型的dropper,以便在运行时使用codedom编译二进制文件。)

Windows 8 has CLR version 4 by default so you can change the runtime by using following code Windows 8默认情况下具有CLR版本4 ,因此您可以使用以下代码来更改运行时

    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup>
    <runtime>
        <NetFx40_LegacySecurityPolicy enabled="true" />
    </runtime>

under configuration section. 配置部分下。 This will change your CLR version. 这将更改您的CLR版本。 I think this will work. 我认为这会起作用。

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

相关问题 我可以在.NET 4.5中使用Windows Identity Foundation 3.5吗? - Can I use Windows Identity Foundation 3.5 with .NET 4.5? WPF 以 .NET 4.5 为目标,但 Windows 要求在应用程序运行时安装 .NET 3.5 - WPF targeting .NET 4.5 but windows asking to install .NET 3.5 when the app run 为什么在Windows7(.net 3.5)中运行的应用程序无法在Win8(.net4.5)中运行 - Why an application working in Windows7(.net 3.5)is not working in Win8(.net4.5) 从.NET 4.5重定向到3.5的Visual Studio 2012项目无法在Windows 7上找到框架 - Visual Studio 2012 project retargeted from .NET 4.5 to 3.5 cannot find framework on Windows 7 在Windows 8.1中仅在Visual Studio 2012中不显示.Net Framework 3.0、3.5、2.0 - .Net framework 3.0, 3.5 , 2.0 not showing in Visual studio 2012 only 4.0 and 4.5 in windows 8.1 使用.NET 4.5构建Windows服务 - Building a Windows Service with .NET 4.5 使用.net 4.5客户端在Windows 7上使用WebSocket的最佳方法 - The best way to use WebSocket on windows 7 with .net 4.5 client 无法在.net 3.5项目中使用Windows脚本宿主对象模型 - Not able to use Windows Script Host Object Model in .net 3.5 project 如何在.NET 3.5 Windows窗体中使用应用程序设置 - How to use application settings in .NET 3.5 Windows Forms 使用.NET 3.5本地化Windows窗体 - Localizing Windows Forms with .NET 3.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM