简体   繁体   中英

Notify user that .exe is targeted for newer version of .NET than is currently installed

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:

在此处输入图片说明

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

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM