ClickOnce Error after upgrading to VS 2008

Posted on November 29, 2007

We recently upgraded to VS 2008 RTM at work, and shortly after discovered that a new build of our ClickOnce-deployed WinForms application failed to install correctly!  During the download process, a message box would display, and the log details revealed an InvalidDeploymentException (RefDefValidation) in System.Deployment.Application.DownloadManager.ProcessDownloadedFile().

Let me just say that days of fruitless investigation followed.

I’m happy to report that I finally did find the solution (completely by accident).  A new option has been added to Visual Studio, allowing you to automatically create and embed a manifest in your application.  This manifest allows you to provide proper application behavior when running under UAC in Vista.  Here’s the option, on the Application property page of the Visual Studio project:

Manifest Options_2

When you upgrade a WinForms project from VS2005 to VS2008, this option is automatically set for you.  If you had identified the application as a ClickOnce application in VS 2005, the resulting deployment from a VS2008 build works correctly.

Real-world ClickOnce

If you’re like me, you’re developing in a professional environment where you can’t just click thePublish Now button and send an app from your development box into production.  Is it just me, or does everyone think that’s insane?  Do you think we might want to QA those phasers first, Captain?

We have a relatively complex build that builds our ClickOnce manifests based on the target environment (Dev, QA, or Production) so that we can test ClickOnce updates from previous versions before going to production.  Also, since we’ve had our ClickOnce app deployed for more than one year, we had to overcome the certificate renewal problem, which requires a special signing process using both the expired and the current signing certificate.  Needless to say, neither of these can be set up in Visual Studio.  What we ended up with is a build where the ClickOnce options are not set in the Visual Studio project, but externally in an MSBuild project file, using many of the built-in targets that VS uses.

Migrating from VS2005

When the project was converted to VS2008, it was upgraded by the wizard as if it wasn’t a ClickOnce project.  This means that the manifest setting was set incorrectly.

Here’s what the Visual Studio documentation has to say about the manifest setting:

Manifest

Selects a manifest generation option when the application runs on Windows Vista under User Account Control (UAC). This option can have the following values:

  • Embed manifest with default settings. Supports the typical manner in which Visual Studio operates on Windows Vista, which is to embed security information in the application’s executable file, specifying that requestedExecutionLevel be AsInvoker. This is the default option.
  • Create application without a manifest. This method is known as virtualization. Use this option for compatibility with earlier applications.
  • Properties\app.manifest. This option is required for applications deployed by ClickOnce or Registration-Free COM. If you publish an application by using ClickOnce deployment, Manifest is automatically set to this option.

The only options I see in the combo box are the first and second.  In our application, “Embed manifest with default settings” was selected by the conversion.  As soon as I chose “Create application without a manifest”, I was able to build, deploy, and download with no trouble at all.

I still need to investigate the manifest issue further.  I want my users to have a great UAC experience with our app, and that means getting the manifest right.  For now though, “create without a manifest” is your quick fix.

Click On!


No Replies to "ClickOnce Error after upgrading to VS 2008"


    Got something to say?

    Some html is OK