2

How can I configure my application to run on both Windows 7 and Windows 8? My application is written in .net 3.5 and it is working fine in windows 7 but for windows 8 the application is asking to turn on .net 3.5 feature. This is because Windows8 has .net framework 4.5 by default. So my question is how can I configure my application to use .net 4.5 in Windows 8 and .net 3.5 in windows 7?

Thanks,

Rup
  • 33,765
  • 9
  • 83
  • 112
mystack
  • 4,910
  • 10
  • 44
  • 75

4 Answers4

1

You can't
Your application must target one .NET framework, you can't target several framework. I would suggest you to target .NET 4 because it's widely installed on windows 7, Windows 8 with 4.5 can run app build for .NET 4. And upgrading from .NET 3.5 to .NET 4 works fine.

Just be sure to target .NET 4 Client Profile because the full .NET 4 is not installed by default on windows computer.

EDIT: More info on upgrading your code from .NET 3.5 to .NET 4 (I just had to do it a few weeks ago so I know what kind of problem could happend).
It'll be EASY to do it unless your code use server side components (i.e System.Web) which are NOT included in the .NET 4 Client Profile and require the full .NET 4 (not installed by default on end-user win7 PC).
Just switch your project to .NET 4 Client profile and check if it's compile. If it's compile it means it doesn't use any server side component.

Fabske
  • 2,106
  • 18
  • 33
0

Follow this link:

http://www.techrepublic.com/blog/10things/10-things-to-try-when-applications-wont-work-with-windows-8/3540

Refer :

Install .NET Framework 3.5

When you install Windows 8, version 4.5 of the .NET Framework is installed by default. However, older apps often require an earlier version of the .NET Framework. If you receive a .NET Framework-related error, you can go into the Control Panel, click on Programs, and choose the option to turn a Windows feature on or off. Windows will display a list of the various components you can enable or disable. One of the items on the list is .NET Framework 3.5, which also includes .NET 3.0 and 2.0. Installing this component will likely correct the issue that you are experiencing.

In that.

Freelancer
  • 9,008
  • 7
  • 42
  • 81
  • 1
    But that requires a manual step by the end user. And even if he could automate that as part of the install, that's not what he wants to do - he wants his app to run using the bundled .NET 4.5. – Rup Apr 08 '13 at 10:07
0

Possible things could be:

  • Compile different assemblies
  • Let the Windows 8 Users install .NET 3.5 (Or the Windows 7 install 4.5)

The best solution would probably build it in 3.5 and just let the Windows 8 Users install .NET 3.5, they probably need it anyway for more applications. There is no such thing that the program decides using .NET 4.0 or .NET 3.5 when its started. (Or you make some sort of dropper that it compiles the binary with codedom at runtime.)

joell
  • 396
  • 6
  • 17
0

Windows 8 has CLR version 4 by default so you can change the runtime by using following code

    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup>
    <runtime>
        <NetFx40_LegacySecurityPolicy enabled="true" />
    </runtime>

under configuration section. This will change your CLR version. I think this will work.

Animesh
  • 323
  • 3
  • 19