Turing
Turing

Reputation: 114

How to deploy windows application to an older .NET Framework

I am building a windows application from Visual studio 2017 using C#. I have a windows 10 system and my .NET Framework by default is 4.7. But I want to run this application in a system which is windows 7 and uses 4.5 .NET Framework.

Therefore, while building this application I have change it's target framework to 4.5, also I have change its supported Runtime from app.config file.

enter image description here

enter image description here

Below is my app.config file:

  <?xml version="1.0" encoding="utf-8"?>
        <configuration>  
    <configSections>
    </configSections>
        <startup>
          <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>      
        </startup>    
        </configuration>

Now when I try to run this application in windows 7, I get the error message "This setup requires the .NET Framework version v4.6.1. Please install the .NET Framework and run this setup again. The .NET Framework can be obtained from the web. Would you like to do this now?. Then when I hit "Yes" button. I get an error "Component Microsoft .NET Framework 4.6.1(x86 and x64) has failed to install with the following error message" " A failure occured attempting to install the Microsoft .NET Framework 4.6.1"

enter image description here

enter image description here

Upvotes: 1

Views: 2187

Answers (6)

Turing
Turing

Reputation: 114

I fixed it, I am posting it incase if someone may have the same issue. My problem with the client machine was, it was window 7 but without any service pack installed. Where else to install the .NET Frame work V4.6.1 your system must be window 7 with SP1. I simply installed the SP1 to client machine window 7 and problem got resolved and I was able to install .NET Framework v4.6.1 hence my software is running. Here is the link. But I haven't figure out how to make my windows application target the desired .NET Framework when building it from VS 2017.

Upvotes: 2

Muhammad Aftab
Muhammad Aftab

Reputation: 1118

You have to install .NET Framework version v4.6.1 on your machine. Find the installer from the below link: https://www.microsoft.com/en-us/download/details.aspx?id=49982

Upvotes: 0

Lukasz Szczygielek
Lukasz Szczygielek

Reputation: 3110

How do you build an installer of your application? Maybe there you have some condition which checks installed .NET Framework version.

Upvotes: 0

Ramil Bayramov
Ramil Bayramov

Reputation: 13

Look at the references, maybe the some library is .NET Framework version v4.6.1

Upvotes: 0

HTTP 410
HTTP 410

Reputation: 17608

There are at least 2 things happening here.

Installation requirements

It appears that the target (Windows 7) machine might not have a 4.5 or higher version of the .NET Framework installed. If that's true, the installation program will try to install v4.6.1 because that's the in-place upgrade for versions 4.0, 4.5, 4.5.1, and 4.5.2. (as outlined here).

Alternatively one or more libraries or other components used by your application need version 4.6.1, even though your core application code doesn't.

Installation issue

The installation problem is likely a separate issue. Have you checked the setup log mentioned in the error message to see more details?

Upvotes: 3

RomanTenger
RomanTenger

Reputation: 81

You have to check if there are any NuGet Packages, using .NET 4.6.1. If this is the case, you have to downgrade them aswell.

Upvotes: 0

Related Questions