Windows 安装 4.x 时提示安装 .NET 3.5
Windows prompting to install .NET 3.5 when 4.x is installed
我有一个用 C#/.NET 编写的小型命令行应用程序。当操作系统上安装了 .NET 3.5 或更高版本时,我需要它 运行。
为此,我 app.config 包含以下内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
项目框架设置为“.NET Framework 3.5”。
根据我的理解,这两个设置应该是向后兼容的,这样当有人没有安装 3.5 但安装了 4.x 时,它会继续工作。
还有什么我想念的吗?根据我的研究,我认为我已经把所有的部分都放在一起来实现它了。
编辑:根据下面的问题,这里还有引用和使用语句。没有第三方组件
项目中参考如下:
System.Core
System.Web.Extensions
System.Windows.Forms
以下是我的使用语句:
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Security.Cryptography;
using System.Web.Script.Serialization;
using System.Reflection;
using System.Diagnostics;
这是 .NET Framework 的一个已知限制 - 从 4 开始,如果前一个(在您的情况下,target 版本) 未安装。
3.5 基于不同的 CLR (2.0),因此存在一些兼容性问题。您需要将您的项目重新定位到 4.0(或更高版本)以避免出现框架安装提示问题。
我有一个用 C#/.NET 编写的小型命令行应用程序。当操作系统上安装了 .NET 3.5 或更高版本时,我需要它 运行。
为此,我 app.config 包含以下内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
项目框架设置为“.NET Framework 3.5”。
根据我的理解,这两个设置应该是向后兼容的,这样当有人没有安装 3.5 但安装了 4.x 时,它会继续工作。
还有什么我想念的吗?根据我的研究,我认为我已经把所有的部分都放在一起来实现它了。
编辑:根据下面的问题,这里还有引用和使用语句。没有第三方组件
项目中参考如下:
System.Core
System.Web.Extensions
System.Windows.Forms
以下是我的使用语句:
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Security.Cryptography;
using System.Web.Script.Serialization;
using System.Reflection;
using System.Diagnostics;
这是 .NET Framework 的一个已知限制 - 从 4 开始,如果前一个(在您的情况下,target 版本) 未安装。
3.5 基于不同的 CLR (2.0),因此存在一些兼容性问题。您需要将您的项目重新定位到 4.0(或更高版本)以避免出现框架安装提示问题。