0

With a simple, single .exe application, is it possible to target a .NET framework version that is newer than the version installed on the end-user's computer, and somehow notify the end-user when launching the application that he/she needs to install a newer version of .NET in order to use the app?

Under normal circumstances when launching a .NET .exe that was compiled for a newer version of .NET than the version that is currently installed, it seems that sometimes there is a comprehensible message popped up stating that to run the application you must first install version X of the .NET Framework. This is good. However, it doesn't necessarily notify to install the correct/needed version (see screenshot below where it says to install 4.0.30319 even though 4.6 is needed), and other times it seems that the popped message is just a generic CLR error with no explanation that it's due to the wrong version of .NET being installed.

Are there any clever ways to produce/display a consistent/reliable more meaningful or customized message to the end user so that there is never a possibility of him/her just receiving a generic CLR error or a message stating that a version of .NET is needed but it states the wrong version to install?

Windows 2008R2 with .NET 3.5.1 installed when app is targeting .NET 4.6:

enter image description here

Windows 2012R2 with .NET 4.5 installed when app is targeting .NET 4.6:

enter image description here

blitz_jones
  • 1,048
  • 2
  • 10
  • 22
  • 1
    People create installers for that purpose (MSI or any other technology you like). – Lex Li Jun 20 '19 at 21:01
  • I know. And then people like me who specifically do not want to use an installer come to SO to ask the community if anyone has a way to do this cleverly with just a single .exe. – blitz_jones Jun 21 '19 at 18:04
  • 1
    You have no clever way to go (unless you decide to write a native app and host CLR on your own, which can only increase your own responsibilities). – Lex Li Jun 21 '19 at 18:07
  • Thanks. I'll probably create some kind of wrapper/pre-launch as suggested by @ZedLepplin unless anyone else chimes in with a different/better idea. – blitz_jones Jun 21 '19 at 18:53

1 Answers1

1

You could code a pre-launch program that checks the windows system to see what is installed. Then you can pop up whatever warning you want, or if all is OK then just launch your main program.

Also, as Lex Li posted, you can create an installer bundle. We use Inno Setup at the place I work, it's free and very comprehensive.

ZedLepplin
  • 307
  • 2
  • 12
  • Can this be done with a single .exe somehow? Or would you essentially have to wrap the main .exe inside of the pre-launch .exe. So like have the pre-launch .exe do the check, and then if all good it can spit out the main .exe for continued/future use. I was hoping to avoid essentially bundling two .exes into one, but that's the only way I can think to do it, unless you can explain how it could all be done as a single .exe. – blitz_jones Jun 21 '19 at 18:03
  • A quick google found this link: - https://stackoverflow.com/questions/951856/is-there-an-easy-way-to-check-the-net-framework-version. One of the problems with one exe is that it would target a particular .net framework. So your program may fall foul of the problem you are already having. A pre launch program could be used to get round this issue. However in order to avoid the .net issue it would, ideally, be written using something that does not use .net. – ZedLepplin Jun 24 '19 at 08:00
  • With regard to the one exe issue, you could use an application packer. This allows you to bundle whatever you want into one exe file. I use this: - https://enigmaprotector.com/en/aboutvb.html – ZedLepplin Jun 24 '19 at 08:14