Show a custom popup if someone doesn't have the required .NET-framework to run an application
I built an application for version 4 of the framework. When I try to run it it says:
In order to run the application, you have to install the following version of the .NET-framework first: v4.0 [...]
That already isn't too bad but it would be great to display a custom message, maybe even with a link to the la开发者_StackOverflow社区test version of the framework.
Is that possible?
There is no straight-forward way of customizing this message. In fact, the message about the unsupported version of the framework is coming from mscoree.dll (i.e. the version of mscoree.dll present on the system).
What you can do is write your own launcher in C++, that will first check whether the required framework version is installed, possibly display a custom message and then host the CLR inside the launcher.
If your application uses a Windows installer package (Wix) then consider listing the framework as a prerequisite, which will let the installer do the check for you and also offer the user the chance to download the framework.
It might not be the best installation mechanism, but if you create a ClickOnce installer you can set the required .NET framework for your application and it will download and install it if it's not present on the target machine.
Yes it is possible, but what platform should the message use?
You would need a bootstrapper, a wrapper that checks and then starts your App.
You could bootstrap with a .NET 2 application if you can assume that Fx2 is installed. But in the future you might see PC's that have Fx4 but not Fx2.
So you will need an unmanaged wrapper to cover the widest range of possibilities.
精彩评论