C# – .Net existence: chicken and eggs

cnet

There are several options for C#-based programs to determine which .Net version is installed. But is it possible to determine if .Net IS installed? I mean if I run C#-program on a machine without any .Net installed, I get the following error:


Myprogram.exe – Application Error

The application failed to initialize properly (0xc0000135). Click on OK to terminate the application.

OK

Yes, I can write a wrapper (some external program or msi-package or somethins like that) but I'm wondering if I can do this sanity check from my C#-program? All I want is to check .Net existence and exit on failure with correct warning like "Microsoft .Net is required. Please install it bla-bla-bla".

Any clue? Thanks.

Best Answer

I think the preferred way to do this is to create an installer for your app and make the .Net Framework a pre-req that the installer checks for.

You can also include the .Net Framework re-distributable components so your installer will install it if it is not found.

See this question for more info.