views:

62

answers:

4

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 latest version of the framework.

Is that possible?

A: 

Yes, it is possible

You need to search in client's registry and search for the version 4.0

Use .net s classes to search in the registry.

saurabh
+1  A: 

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.

STW
+1  A: 

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.

ChrisF
+3  A: 

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.

0xA3
Would you really need to host the CLR? I think a simple Process.Start (equiv) would do.
Henk Holterman
@Henk Holterman: Sure it would; but I think such a mechanism only makes sense if you want to deploy a single file to the user (instead of using the recommended installer/bootstrapper approach). For example, what happens if users double-click the actual .NET assembly and not my launcher? Then all my customization was in vain.
0xA3
using the `Process.Start()` approach also goes against the grain with Win7. If your user wants to pin your application to their task-bar, for example, they would have to pin the launcher which would close nearly immediately. Having your startup .exe running for the duration of the application is much more intuitive
STW