Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
95 views
in Technique[技术] by (71.8m points)

c# - Target Version of the .NET Framework does not match Launch Condition

I have a c# project that I am building in VS 2010. It references a C++ project through COM, which is also a part of the solution. Last Friday, I made a successful build, changed a single line of code, made another build, and I started getting an error about .NET.

The target version of the .NET Framework in the project does not match the .NET Framework launch condition version '.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#).

  • Project -> Properties -> Application -> Target Framework (for each project in both Debug and Release)
  • Project -> Properties -> Publish -> Prerequisites (confirmed .NET 3.5 and Windows Installer 3.1)
  • Setup -> Launch Conditions -> .NET Framework
  • Setup -> Properties -> Prerequisites

I have also reviewed the vdproj code for my installer, confirming the launch conditions were .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. The second one, for the x86 processor, does not get the .NET error. I have compared the code in its vdproj with this, and it looks the same.

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. I changed it back, and it gave me the .NET version error again. 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.

"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.

question from:https://stackoverflow.com/questions/15770318/target-version-of-the-net-framework-does-not-match-launch-condition

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To alter it through the UI (not a text editor). Taken from here.

1) Select installer project

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).

3) Under Launch Conditions, Select ".Net framework" on the right in "Properties" Select "Version" you will see a drop down. change the framework to your target framework.

4) Build and install.

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. Update the .NET Framework launch condition to match the version of the .NET Framework selected in the Prerequisites Dialog Box.

Perform the following steps:

1) Right click the installer project and click 'properties'.

2) Click on the 'Prerequisites' button.

3) Change as desired.

EDIT: Updated the Launch Conditions Editor icon description for different version of VS, as per the comments.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...