[英]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? 使用简单的单个.exe应用程序,可以定位比最终用户计算机上安装的版本更高的.NET Framework版本,并在启动该应用程序时以某种方式通知最终用户他/她需要安装新版本的.NET以便使用该应用程序?
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. 通常情况下,当启动的.NET .exe是为比当前安装的.NET更高的版本编译的.NET时,似乎有时会弹出一条可理解的消息,指出要运行该应用程序,您必须先安装该版本.NET Framework的X。 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.
但是,它不一定会通知您安装正确/所需的版本(请参见下面的屏幕快照,即使需要4.6也要安装4.0.30319),而在其他情况下,弹出的消息似乎只是一个通用的CLR错误,带有没有说明这是由于安装了错误的.NET版本造成的。
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? 是否有任何聪明的方法可以向最终用户生成/显示一致/可靠的,更有意义的或自定义的消息,从而使他/她永远不可能仅收到一般的CLR错误或表明.NET版本是需要,但显示安装错误的版本?
Windows 2008R2 with .NET 3.5.1 installed when app is targeting .NET 4.6: 当应用程序针对.NET 4.6时安装了.NET 3.5.1的Windows 2008R2:
Windows 2012R2 with .NET 4.5 installed when app is targeting .NET 4.6: 将应用定位到.NET 4.6时安装了.NET 4.5的Windows 2012R2:
You could code a pre-launch program that checks the windows system to see what is installed. 您可以编写一个预启动程序,以检查Windows系统以查看安装了什么。 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. 另外,如Lex Li所介绍的,您可以创建安装程序包。 We use Inno Setup at the place I work, it's free and very comprehensive.
我们在我工作的地方使用Inno Setup,它是免费的并且非常全面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.