tags:

views:

109

answers:

2

So I have an app (tool) that uses .NET 3.0. When run on a machine that only has .NET 2.0 (like the default Server 2008 R2 install) it crashes miserably.

What I've seen so far is that people are using a shunt that will first check the .NET version. Is there a way to build it or add some manifest somehow so that the user is warned of this problem (and hopefully be prompted to install .NET)?

I know this can be solved by an installer, but I have requirements that need it to be a standalone executable. (Ok this is hard to explain, but it's related to the a device driver. The tool comes with the driver, but the user shouldn't be forced to install .NET 3.0 if they won't use the tool.)

I just need to stop at the point where a cryptic "application has failed with exception 0xe0434f4d" message and at the very least give the user some idea of what happened.

+4  A: 

Have not tested this, but this article about framework detection tells how you could detect the framework version from code. I'm not sure where your application fails and if injecting checks like this could solve your problem, but if you cannot use this in your app, you could perhaps create a small "starter app" in old .net 2.0 that performs these checks and then either tells the user to upgrade or starts your "real" app?

As I said, haven't tested this approach, it's just off the top of my mind.

wasatz
+1 Great answer. I was going to suggest to create a "launcher" in .NET 2 (or whatever the minimum the OP supports) but was lacking a way to accurately find the .NET version. `Environment.Version` just reports the CLR version, which for 3.0 and 3.5 is still 2.0.
Andy Shellam
THis is just the shunt approach i was talking about.
moogs
Usually that check should be performed in installers. But a launcher is not a bad idea if it is light weighted.
Lex Li
+4  A: 

This never makes any sense to me. Where are you going to stop? Are you going to make sure as well that the user doesn't install it on Windows 98? That the machine has enough RAM? That the user account has enough privileges?

Software vendors publish system requirements. You always quote the lowest supported Windows version, minimum amount of RAM, required disk space, minimum browser version, etc. Minimum .NET framework version belongs in that list too. The intention of this list is clear: don't expect it to work properly if you don't meet the requirements. If you do it anyway, it is your problem, not mine.

This is different for a consumer-level app. But when you install to Windows 2008 server, you are not writing a consumer app.

Hans Passant
I just need to stop at the point where a cryptic "application has failed with exception 0xe2334abcb" message and at the very least give the user some idea of what happened.
moogs
Spending one or two days or this problem for a possible solution is worth the bajillion hours of support calls for users who don't read manuals (most everyone).
moogs