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

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.

Submit a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s