Windows Develop Bookmark and Share   
 index > Windows Forms General > sample code for programmincally install the "correct version" of .net framework?
 

sample code for programmincally install the "correct version" of .net framework?

Hi, I wrote a very simple window form app, all it has is a label and couple buttons. When I send to exe file to another machine, it pops the famous error message: The application failed to initialize properly (0xc0000135). Click on OK to terminiate the application.

Then I learned, the target machine needs to have .net framework install and the version of the framework must match where my app was built.

My question:

Does anyone have sample code for my program to determine if the target machine has the correct version of .net framework installed, and if not then my program would automatically download from msdn and install for user...etc etc etc?

Or if there are better ways to handle it (such maybe using the deploy option from vs.net which i never used before, and dunno how it works, anyone got sample steps please)?

Thank you for your time :)

p.s: i'm using vs.net2003
sirpelidor  Tuesday, October 17, 2006 4:51 AM

not really since if you don't have the .NET Framework installed, you can't even load your application....so the code won't even execute

The best way would be to create a setup and deployment project, or clickonce, which will automatically download and install the .NET Framework on the machine before proceeding to install your application and making it run successfully

to create this setup and deployment project, take a look at this thread, which also has some links to other threads.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=831649&SiteID=1

ahmedilyas  Tuesday, October 17, 2006 8:17 PM

As far as I am aware you are not going to be able to add any routines to your existing application because it will obviously not run because the .NET framework is not installed.

Can you not create a simple setup application which will automatically detect if or not you have the framework installed? I have not used vs2003 for a long time but i believe there is a setup wizard which you can use. Alternatively you could use any one of the free ones available (WiX, NSIS etc) but you will have to code them yourself and add the framework checking routines in yourself.

Hope that helps

wayne_boyles  Tuesday, October 17, 2006 8:43 AM
That wouldn't be necessary. In the main program code, (the one that launches your form), do a check.

if (System.IO.Directory.Exists("Path to .NET Framework 2.0 folder")
{
// then launch your form
}
else
{
// then close your application fully
}
Ðãvę Âņđęŕŝőŋ1  Tuesday, October 17, 2006 7:36 PM

not really since if you don't have the .NET Framework installed, you can't even load your application....so the code won't even execute

The best way would be to create a setup and deployment project, or clickonce, which will automatically download and install the .NET Framework on the machine before proceeding to install your application and making it run successfully

to create this setup and deployment project, take a look at this thread, which also has some links to other threads.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=831649&SiteID=1

ahmedilyas  Tuesday, October 17, 2006 8:17 PM

hi ahmedilyas, although your post was useful, it was gear toward vs2005. You don't happen have any direct link or sample code for me to apply in vs.net 2003?

thank you

sirpelidor  Thursday, October 19, 2006 2:24 AM
same thing applies for VS2003 :-) Just create a new setup and deployment project, do your thing as stated and it will automatically download and install the .NET Framework on the machine you are installing the application on
ahmedilyas  Thursday, October 19, 2006 2:28 AM

You can use google to search for other answers

Custom Search

More Threads

• Call main thread in a windows form
• How can I make columns in listbox?
• RichTextBox hyperlinks
• Object reference not set to an instance of an object.
• Active desktop
• Designer Code Generator (DesignMode)
• Regarding StatusStrip and StatusBar issues
• limit lines in a listbox
• form timer control strange behaviour
• Delegates between a main thread and a sub thread