简体   繁体   English

.NET Framework 的目标版本与启动条件不匹配

[英]Target Version of the .NET Framework does not match Launch Condition

I have ac# project that I am building in VS 2010. It references a C++ project through COM, which is also a part of the solution.我有我在 VS 2010 中构建的 ac# 项目。它通过 COM 引用了一个 C++ 项目,这也是解决方案的一部分。 Last Friday, I made a successful build, changed a single line of code, made another build, and I started getting an error about .NET.上周五,我进行了一次成功的构建,更改了一行代码,又进行了一次构建,然后我开始收到有关 .NET 的错误消息。

The target version of the .NET Framework in the project does not match the .NET Framework launch condition version '.NET Framework 3.5'.项目中 .NET Framework 的目标版本与 .NET Framework 启动条件版本“.NET Framework 3.5”不匹配。 Update the version of the .NET Framework launch condition to match the target version of the .NET Framework in the Advanced Compile Options Dialog Box (VB) or the Application Page (C#, F#).在高级编译选项对话框 (VB) 或应用程序页面(C#、F#)中更新 .NET Framework 启动条件的版本以匹配 .NET Framework 的目标版本。

  • Project -> Properties -> Application -> Target Framework (for each project in both Debug and Release)项目 -> 属性 -> 应用程序 -> 目标框架(针对 Debug 和 Release 中的每个项目)
  • Project -> Properties -> Publish -> Prerequisites (confirmed .NET 3.5 and Windows Installer 3.1)项目 -> 属性 -> 发布 -> 先决条件(确认 .NET 3.5 和 Windows Installer 3.1)
  • Setup -> Launch Conditions -> .NET Framework设置 -> 启动条件 -> .NET Framework
  • Setup -> Properties -> Prerequisites设置 -> 属性 -> 先决条件

I have also reviewed the vdproj code for my installer, confirming the launch conditions were .NET 3.5:我还查看了我的安装程序的 vdproj 代码,确认启动条件是 .NET 3.5:

"ComponentsUrl" = "8:"
"Items"
{
    "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Net.Framework.3.5.SP1"
    {
        "Name" = "8:.NET Framework 3.5 SP1"
        "ProductCode" = "8:Microsoft.Net.Framework.3.5.SP1"
    }
    "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Windows.Installer.3.1"
    {
        "Name" = "8:Windows Installer 3.1"
        "ProductCode" = "8:Microsoft.Windows.Installer.3.1"
    }
}

"ComponentsUrl" = "8:"
"Items"
{
     "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Net.Framework.3.5.SP1"
     {
         "Name" = "8:.NET Framework 3.5 SP1"
         "ProductCode" = "8:Microsoft.Net.Framework.3.5.SP1"
     }
     "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Windows.Installer.3.1"
     {
         "Name" = "8:Windows Installer 3.1"
         "ProductCode" = "8:Microsoft.Windows.Installer.3.1"
     }
}

"LaunchCondition"
{
    "{A06ECF26-33A3-4562-8140-9B0E340D4F24}:_799EF2A78D074B669D0B30310FD56A67"
    {
        "Name" = "8:.NET Framework"
        "Message" = "8:[VSDNETMSG]"
        "FrameworkVersion" = "8:.NETFramework,Version=v3.5"
        "AllowLaterVersions" = "11:FALSE"
        "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=131000"
    }
}

Since I build for both an x86 and x64 compiler, I have two setup projects.由于我为 x86 和 x64 编译器构建,我有两个安装项目。 The second one, for the x86 processor, does not get the .NET error.第二个,对于 x86 处理器,没有得到 .NET 错误。 I have compared the code in its vdproj with this, and it looks the same.我已经将其 vdproj 中的代码与此进行了比较,它看起来是一样的。

I have found several threads on this issue, including a very good one here , but none of them have helped me resolve this issue.我在这个问题上找到了几个线程,包括一个非常好的这里,但它们都没有帮助我解决这个问题。 Any suggestions would be helpful.任何的意见都将会有帮助。

EDIT编辑

I changed everything to .NET 4.0 just to see if it made a difference, and the project built successfully.我将所有内容都更改为 .NET 4.0 只是为了看看它是否有所作为,并且该项目已成功构建。 I changed it back, and it gave me the .NET version error again.我把它改回来了,它又给了我 .NET 版本错误。 I checked the vdproj file for any "4.0" reference, and only found it for the AspNetVersion, which also occured in the x86 version of the installer which works.我检查了 vdproj 文件中是否有任何“4.0”参考,并且只找到了 AspNetVersion,它也出现在 x86 版本的安装程序中。

"AspNetVersion" = "8:4.0.30319.0"

I need to release with .NET 3.5, so this was just an exercise to see if changing the version to something else and back would resolve the issue.我需要使用 .NET 3.5 发布,所以这只是一个练习,看看将版本更改为其他版本并返回是否可以解决问题。

To alter it through the UI (not a text editor).通过 UI(不是文本编辑器)更改它。 Taken from here .取自这里

1) Select installer project 1) 选择安装项目

2) In Solution Explorer or Solution Navigator click on the icon at the top of the panel "Launch Conditions Editor" (In VS2010 its the icon with binoculars, in VS2015 and VS2017 the icon is a sheet of paper with a filter in front of it (shout out to Mat and Bob Van de Vijver in the comments). 2) 在解决方案资源管理器或解决方案导航器中单击面板顶部的图标“启动条件编辑器”(在 VS2010 中它是带双筒望远镜的图标,在 VS2015 和 VS2017 中该图标是一张纸,前面有一个过滤器(在评论中向 Mat 和 Bob Van de Vijver 大喊大叫)。

3) Under Launch Conditions, Select ".Net framework" on the right in "Properties" Select "Version" you will see a drop down. 3)在启动条件下,在“属性”中选择右侧的“.Net框架”选择“版本”,您将看到一个下拉列表。 change the framework to your target framework.将框架更改为您的目标框架。

4) Build and install. 4) 构建和安装。

If you then receive a message similar to the following:如果您随后收到类似于以下内容的消息:

WARNING: The version of the .NET Framework launch condition '.NET Framework 4' does not match the selected .NET Framework bootstrapper package.警告:.NET Framework 启动条件“.NET Framework 4”的版本与选定的 .NET Framework 引导程序包不匹配。 Update the .NET Framework launch condition to match the version of the .NET Framework selected in the Prerequisites Dialog Box.更新 .NET Framework 启动条件以匹配在先决条件对话框中选择的 .NET Framework 版本。

Perform the following steps:执行以下步骤:

1) Right click the installer project and click 'properties'. 1) 右键单击​​安装程序项目,然后单击“属性”。

2) Click on the 'Prerequisites' button. 2) 单击“先决条件”按钮。

3) Change as desired. 3) 根据需要更改。

EDIT: Updated the Launch Conditions Editor icon description for different version of VS, as per the comments.编辑:根据评论更新了不同版本 VS 的启动条件编辑器图标说明。

It turns out that the C++ code was also associated with .NET for some reason.事实证明,出于某种原因,C++ 代码也与 .NET 相关联。 I used this article to help me change the c++ .NET version from 4.0 to 3.5.我使用这篇文章帮助我将 c++ .NET 版本从 4.0 更改为 3.5。 The basic steps are基本步骤是

  1. Open the c++ project vcxproj in a text editor在文本编辑器中打开 c++ 项目 vcxproj
  2. Find <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>找到<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    • This may need to be created under the Globals PropertyGroup这可能需要在 Globals PropertyGroup 下创建
  3. Change 4.0 to 3.5将 4.0 更改为 3.5
  4. Open the project in VS在VS中打开项目
  5. Right click the c++ project and select properties右键单击 c++ 项目并选择属性
  6. Select Common Properties and confirm that the version is 3.5选择 Common Properties 并确认版本为 3.5
  7. Select Configuration Properties -> General选择配置属性 -> 常规
  8. Make sure the Platform Toolset is set to v90确保平台工具集设置为 v90

Had same problem as this project had been converted from 2008 to 2010.与该项目从 2008 年转换到 2010 年有同样的问题。

To change the bootstrapper, I opened the .csproj and manually removed instances from 3.5 in it:为了更改引导程序,我打开了 .csproj 并从其中手动删除了 3.5 中的实例:

<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
  <Visible>False</Visible>
  <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
  <Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
  <Visible>False</Visible>
  <ProductName>.NET Framework 3.5 SP1</ProductName>
  <Install>false</Install>
</BootstrapperPackage>

Also, I found out you can just right click on the Setup and Deployment project, hit properties, go to prerequisites, and select the correct .NET framework.此外,我发现您只需右键单击 Setup and Deployment 项目,点击属性,转到先决条件,然后选择正确的 .NET 框架即可。

It was hard to find it, you have to click on the Prerequisites button.很难找到它,您必须单击先决条件按钮。

I was also facing the same issue.I made a mistake that target frame work was different at all places.U can verify that at below mentioned places same framework should be selected.I am using VS2015.我也面临同样的问题。我犯了一个错误,目标框架在所有地方都不同。你可以验证在下面提到的地方应该选择相同的框架。我使用的是VS2015。 Place 1 - right click on Project-> Properties -> application -> target framework for me (.Net framework 4) you can select according to your project. Place 1 - 右键单击​​Project-> Properties -> application -> target framework for me(.Net framework 4)您可以根据您的项目进行选择。 Place 2 - Right click on installer project -> properties -> prerequisites-> select microsoft framework 4 (X86 and X64) for u it depends which framework you target.位置 2 - 右键单击​​安装程序项目 -> 属性 -> 先决条件 -> 为您选择 microsoft framework 4(X86 和 X64)这取决于您的目标框架。 Place 3 - Right click on Installer project -> click on view-> launch condition -> .net Framework -> right click properties-> select >net framework 4. I was working with windows services and facing this issue while updating from vs 2010 to 2015.Hope it will help you.位置 3 - 右键单击​​安装程序项目 -> 单击视图 -> 启动条件 -> .net Framework -> 右键单击​​属性 -> 选择 >net 框架 4. 我正在使用 Windows 服务并在从 vs 2010 更新时遇到这个问题到 2015.Hope 它会帮助你。

Even after setting the framework version and Setup project prerequisites in all the places mentioned above.即使在上述所有地方设置了框架版本和安装项目先决条件之后。 The error continued to appear.错误继续出现。 I then looked in the setup project file and saw the previous NET framework version was still mentioned under the Configurations/Debug section, so in Visual Studio I set the compile mode back to Debug, repeated the same changes and that cleared the error for me.然后我查看了安装项目文件,看到配置/调试部分下仍然提到了以前的 NET 框架版本,因此在 Visual Studio 中,我将编译模式设置回调试,重复相同的更改并为我清除了错误。

  • On main menu select "Project"在主菜单上选择“项目”
  • Select option " Properties"选择选项“属性”
  • A form will open, select "Build", click on button "Prerequisites", select your .Net version.将打开一个表单,选择“构建”,单击“先决条件”按钮,选择您的 .Net 版本。

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

相关问题 修复 WARNING: The target version of the .NET Framework in the project does not match the .NET Framework launch condition version C# Setup Project - Fix the WARNING: The target version of the .NET Framework in the project does not match the .NET Framework launch condition version C# Setup Project Target.NET 框架版本与安装的 .NET 框架版本 - Target.NET framework version vs .NET framework version installed .net 框架到 .net 5 迁移构建但不启动 - .net framework to .net 5 migration build but does not launch 运行时使用的应用程序框架版本目标和Net Framework版本 - Application framework version target and Net Framework version used in runtime 为什么具有相同目标框架版本的两个应用程序的.NET版本不同 - Why .NET version is different for two app with same target framework version VS 安装项目 - .Net Framework 3.5 或更高版本的启动条件 - VS Setup Project - Launch condition for .Net Framework 3.5 or higher 启动条件阻止静默安装(Application + .Net Framework) - Launch condition prevents silent installation (Application + .Net Framework) 针对特定的.NET框架 - Target a specific .NET framework 选择.NET Framework目标 - Select .NET Framework target .NET Framework SDK如何与可用的目标框架相关联? - How does .NET Framework SDK relate to available target frameworks?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM