Jun 08

WPF/XBAP IOException: Cannot locate resource app.xaml

I’m working on an XBAP project where deploying it involves publishing it as a ClickOnce manifest using Visual Studio 2008′s publishing features. I’m working with the RTM version Visual Studio 2008 Professional Edition.

Occasionally, the publishing process would fail for no good reason even though the project compiled successfully. When the publishing process eventually succeeded, I would get the following error when running the application:

IOException: Cannot locate resource app.xaml

After that happened, I wouldn’t even be able to run the project in Debug mode from Visual Studio – I would get the same error.

In order to get the project to run again, I would have to open app.xaml, edit it, undo the edit, and save it. Blew my mind.

An extensive Google search showed that most people reported this issue when using the Beta 2 build of Orcas. I can report that this issue still occurs in the RTM version.

I finally figured this out, and am now able to publish my project consistently without ever seeing this error. Here’s what my publishing process looks like now:

  1. If your project is under source control, your .csproj or .vbproj needs to be checked out
  2. You need to delete previously published files
    • Delete the contents of publish
    • Delete the contents of binDebugapp.publish
      • or binReleaseapp.publish
    • EDIT: I also noticed that I need to have the “Automatically increment revision with each publish” checkbox on the Publish tab of the project properties checked.

I hope this saves you some frustration.

37 comments , permalink