4

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
  • And your requirements are you have just one single file? I would be surprised of any .NET assembly would be able to tell the user he needs to install the framework. Mar 26, 2010 at 10:57
  • 1
    I'd be interested to hear your requirements that need it to be a standalone executable. ClickOnce is perfect for checking the dependencies of the machine, including downloading and installing .NET, checking for and installing updates, automatically, and it's minimally-intrusive, even though it does qualify as an installer ;-) Mar 26, 2010 at 11:04
  • 3
    Just convince whoever sets these requirements that an installer is a lesser evil. Going down this path will lead nowhere good and you'll end up implementing your own installer in the end anyway.
    – dkackman
    Mar 26, 2010 at 13:16
  • What's really crazy is the crash message in the first place. There should be a stub that says what .NET version is needed! Mar 27, 2010 at 3:06

2 Answers 2

4

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.

3
  • +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. Mar 26, 2010 at 11:02
  • THis is just the shunt approach i was talking about.
    – moogs
    Mar 27, 2010 at 2:19
  • Usually that check should be performed in installers. But a launcher is not a bad idea if it is light weighted.
    – Lex Li
    Mar 27, 2010 at 3:21
4

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.

2
  • 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
    Mar 27, 2010 at 2:15
  • 2
    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
    Mar 27, 2010 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.