4. Windows提示安装.net 3.5时.已安装X

本文关键字:安装 5时 net Windows 提示 | 更新日期: 2023-09-27 18:11:17

我有一个用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语句:

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;

4. Windows提示安装.net 3.5时.已安装X

这是一个已知的。net框架的限制-从4开始,它不允许应用程序在自己的运行时内执行,如果以前的(在你的情况下,目标版本)没有安装。

3.5基于不同的CLR(2.0),因此存在一些比较问题。您需要将您的项目重新定位到4.0(或更高版本),以避免框架安装提示的问题。

推荐阅读:CLR内外并行