Hello there! It looks like this might be your first time to my website. You should...
Subscribe to my
RSS feed
Follow me
on Twitter.
Check out
.NET Dev Buzz

ClickOnce Deployment for Unmanaged Code (C++, VB6, etc)

Monday, August 25, 2008 7:53:30 PM (Pacific Standard Time, UTC-08:00)

ClickOnce is a great deployment model for many Windows applications built with the .NET Framework. Too bad it isn't supported for C++, VB 6, or other technologies. Or is it...

Surprisingly, you can deploy your unmanaged apps with ClickOnce. You just need a tiny .NET app to get it started.

Here's how it works:

  1. Take your existing C++ project.

  2. Add to the solution a .NET console application.

  3. Change the project settings on the console application to "Windows Application".

  4. Write the following code for your Main method of your .NET launcher application:
    static void Main(string[] args)
    {
        try
        {
            Process.Start( "TheRealApp.exe" );
        }
        catch ( Exception x )
        {
            string msg = "Error launch application:\n\n" + x;
            string cap = "Error Launching Application";
            MessageBox.Show( msg, cap, MessageBoxButtons.OK, MessageBoxIcon.Error );
        }
    }
    
  5. Set the build path of your C++ app to be in the main folder for your .NET application.

  6. Add the C++ app and its libraries (if any) as existing items in the .NET app.

  7. Change the build action to "Always Copy" as shown here:




  8. Then you publish your .NET application and when it runs, TADA!, the C++ app is deployed, versioned, and kept up to date as well.



If you want to try it yourself, you can run this sample application here:

   Run Michael's Useless C++ App via ClickOnce...

You can also download the source.



Tweet this Follow me on Twitter Post this to dotnetshoutout.com Digg this Submit this to Stumbleupon email this post


Just a site note: I'm doing my part to rid the world of IE 6. Visit this site with IE 6 and you'll get a shameful message telling you to "Stop Living in the Past".