开发者

.Net existence: chicken and eggs?

开发者 https://www.devze.com 2022-12-13 04:07 出处:网络
There are several options for C#-based programs to determine which .Net version is installed. But is it possible to 开发者_Go百科determine if .Net IS installed? I mean if I run C#-program on a machine

There are several options for C#-based programs to determine which .Net version is installed. But is it possible to 开发者_Go百科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.


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.


If you create a ClickOnce installer and add the .NEt version you need as a prerequisite, then this check will be done for you when your users install your program for the first time.


No, C# cannot check for the existence of .NET. It's like asking if you can write a program to check if the computer is turned on.

You'd need to write native code to check this, or more preferably, an installer that checks this.


You can use Bootstrapper Plug-in and the framework will be bundled with your application.

0

精彩评论

暂无评论...
验证码 换一张
取 消