5

I have created a WPF application which should natively run on Windows 7, 8, 8.1, 10.

In Visual Studio, I have set .NET Framework to 3.5 as it is bundled with Windows 7. When I run it on Win10, however, it prompts to install .NET 3.5 as Win10 is bundled with 4.6 and does not have 3.5 installed by default.

How can I make my application run on all Windows versions >= 7 without getting any prompts from Windows and without installing anything?

janhartmann
  • 14,713
  • 15
  • 82
  • 138
Sukrit Gupta
  • 438
  • 4
  • 18
  • 2
    I would expect all Windows 7 machines to have .NET 4.0 or above installed by now. – ChrisF Dec 09 '15 at 09:46
  • 1
    You'll most likely need to include it in your installer. You can't run your application without its requirements by their very definition... (And @ChrisF, I wish that was the case on my last project where a lot of our users were using dodgy copies of windows and didn't want to install windows updates to avoid detection).. – Sayse Dec 09 '15 at 09:48
  • 1
    @Sayse - ah. I hadn't considered that :( – ChrisF Dec 09 '15 at 09:49
  • @ChrisF I also Expect the same, but I need to be sure.. :) – Sukrit Gupta Dec 09 '15 at 09:50
  • @Sayse I am building CD Top level setup launcher. User select a prog in it and then it is installed. Can't install .net framework to run the setupLauncher itself.. – Sukrit Gupta Dec 09 '15 at 09:52
  • 1
    @Danton - You may need to consider writing the launcher with 3.5 then, although from my experience in my previous comment we eventually just told our customers to find a way to upgrade as it would benefit them with more than just our software I think. I think its kind of accepted as an end user that these kind of pop-up's are shown, provided they show a solution – Sayse Dec 09 '15 at 09:55

3 Answers3

5

IT CAN WORK, found the solution:

We need to modify app.config file and put below lines in it:

<startup>
 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
 <supportedRuntime version="v4.0"/>
 <supportedRuntime version="v2.0.50727"/>
</startup>

It decides from top to bottom, whichever first version of .net is found as per above list it works on that.

CATCH: After building, a ProgramName.exe.config file is made in release folder, we need to copy it with our ProgramName.exe to the system in which we want to run..

Sukrit Gupta
  • 438
  • 4
  • 18
  • Just curious as to why you're telling the runtime to fall back to 2.0 when your requirement is that it run on .NET 3.5 and upwards (i.e. Windows 7 & upwards) and you're building against 3.5? – ardila Dec 09 '15 at 11:41
  • 1
    @aardila the answer is quite clear. It uses .NET 2.0 as runtime, because .NET 3.5 *uses* .NET 2.0 as its runtime. There's no .NET 3.5 specific runtime. – Eriawan Kusumawardhono Dec 09 '15 at 19:03
  • @EriawanKusumawardhono Thanks for the clarification on the 3.5 runtime. That said, I wasn't challenging the clarity of the answer, and as it doesn't include the information you've just provided it leaves room for clarification, hence my question – ardila Dec 11 '15 at 09:01
  • @ardila To be more accurate, .NET 3.5 uses *CLR* 2.0 instead of *.NET* 2.0. [Wikipedia](https://en.wikipedia.org/wiki/.NET_Framework#Release_history) has good correspondence. – Franklin Yu Sep 26 '18 at 15:09
1

You can create an installer that installs your app + .NET 4.5 to client's computer silently. That way your app will run seamlessly on every OS.

Fandi Susanto
  • 2,272
  • 1
  • 26
  • 25
  • It'll either increase size of installer or will need internet connection + time gone in installation that too silent wouldn't be pleasing to user.. – Sukrit Gupta Dec 09 '15 at 10:09
  • The .NET 4.5 framework is far less bulky as .NET 3.5. IMO adding that extra 67MB to your installer wont hurt much. And let me correct myself about silent install. I mean in the installer you can detect .NET 4.5 installation and install as needed. There would be .NET 4.5 installation UI visible. So it's not too silent. And btw, i've had bad experience when developing on 4.5 machine and deploy on 3.5 machine. Some bug only appears on deployed machine. – Fandi Susanto Dec 10 '15 at 06:08
0

I don't think you can. Even if there is .net in windows 10. The update system in Microsoft is such, that it doesn't overwrite your current applet (as for instance Chrome) but adds more to the system (Check your Control Panel/Uninstall Programs to see how many instances of Microsoft C++/.NET you have)

Иво Недев
  • 1,570
  • 1
  • 20
  • 33