Thursday, February 25, 2010

context.xml not installing when using ClickOnce

We had an WPF application and were using ClickOnce to deploy the application.  When we installed the application, we got an error that looked like it could either be on install or startup.  After further investigation we found it was when we started the application.  The specific error I got was a - An unhandled exception (system.TypeInitializationException) occurred in ...  It turned out that the context.xml file that we were using with our application wasn't installed by ClickOnce.  The reason was that we had specified it as an embedded resource.  To fix it, click on the file, and then in the "Build Action" property change it to "Content".  Then right-click on your project and go to properties, and click on the "Publish" tab (I'm using Visual Studio 2008), and click on the "Application Files" button.  In the window that pops up, you should see "context.xml".  In the "Publish Status" column, make sure that you have "Include" selected, and in the "download group" specify "Required" and in the Hash column have "Include".

More information can be found here - http://blogs.msdn.com/karstenj/archive/2006/02/21/536322.aspx

For me this fixed the problem.

No comments: