Allan Cady

I have a WPF app that I built from scratch using Visual Studio 2008 Beta 2. It compiles and runs fine in the folder where I created it originally.

I got it to a point where I was ready to commit it to posterity, at which point I checked the solution into our source control repository (Subversion). When I check out a clean copy, I can build, but I get the following exception when I try to run:

System.IO.Exception "Cannot locate resource 'window1.xaml'."

When I checked it in, I followed the procedure that I've followed in the past when checking in WPF apps:

1) Create the empty repository

2) Check out the empty repository into a new folder

3) Copy the solution folder into the checkout folder

4) Delete the bin and obj folders and the .suo file

5) Add and commit the remaining files and folders

6) Open the .sln file in Visual Studio. Re-set the correct project as the startup project, then F5 to build and run.

At that point I get the exception.

I repeated this without the source-control steps, i.e. I just did steps 3, 4 and 6 into a separate folder, and got the same result. So something's getting lost in step 4.

Is this a bug, or do I need to revise my procedures for VS 2008

Thanks,

Allan



Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Mike Cook - MSFT

Can you reproduce the issue with a small test project, or does the problem only occur with this particular one

I can't seem to reproduce the problem myself, but it sounds like the StartupUri in App.xaml is no longer matching up with the location of 'Window1.xaml'. Has 'Window1.xaml' moved in relation to 'App.xaml'

-Mike






Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Allan Cady

Likewise, when I created a bare-bones WPF project, the problem didn't reproduce.

Your hint was what I needed to find the problem. At some point I had changed the project's namespace, but this change didn't get made in App.xaml.

In Window1.xaml I had:

<Window x:Class="NewNamespace.Window1" ... />

In Window1.xaml.cs I had:

namespace NewNamespace

{

public partial class Window1 : Window

In App.xaml.cs I had:

namespace NewNamespace

{

public partial class App : Application

But in App.xaml, I had:

<Application x:Class="OldNamespace.App"

...

StartupUri="Window1.xaml">

Changing OldNamespace.App to NewNamespace.App fixed the problem. Of course, it would have been nice if the compiler had caught this. Maybe in the future...

Thanks.





Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Allan Cady

OK, it looks like I spoke too soon. I made some further changes to the app, did a fresh clean checkout, and tried again, and the old problem came back.

After playing around with this a little, I've made the following discovery: if I get a clean copy, build once, then run, it fails (same error as at the beginning.) If I get a clean copy, build once, open App.xaml and make a trivial change like add a space, rebuild, then run, the error goes away.

It's hard for me to imagine how this could not be a bug in Visual Studio. Of course the fact that we don't see the problem in a trivial project makes it a little harder to debug...

If you would like to try it on my project, contact me directly and I'll send you a zip file.

-Allan





Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Allan Cady

It just occurred to me, I might be more likely to get your attention again if I reply directly to your post. Please see my most recent comment.

Thanks,

Allan





Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Mike Cook - MSFT

I'd be happy to take a look at it for you.

The easiest way for me to look at it would be to just throw the ZIP up on SkyDrive. Since I know you have a Live ID (since you're posting on this forum) just go to http://skydrive.live.com and post the ZIP in your public folder. Then post a link to the file here.

-Mike






Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'


Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Allan Cady

Mike,

Did you ever get a chance to try out my project

Thanks,

Allan





Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

David Cater

For what it's worth, this seems to happen to me all the time when downloading sample apps and trying to build them. I saw a suggestion in another post that always works for me. Edit App.xaml, add a space and remove it, save it, and rebuild. Magic happens. The app can build again and the initial Xaml file can be found again.

I don't have any idea why this works. Since it seems fairly easy to reproduce with a simple app, I would imagine you might be able to diagnose it with DILE and get some insight into why its happening.

David





Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Allan Cady

Yes, I noted that workaround in my Sept. 6 post. I think it deserves some attention by somebody at MS nonetheless.




Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

David Cater

I totally agree. And thanks for pointing that out in the earlier post. I was getting rather frustrated. :-)





Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Mike Cook - MSFT

Hi Allan,

Sorry I overlooked your previous reply. I tried out the DailyDataExplorer demo that you posted and I am able to reproduce the problem. Let me get ahold of someone on the Visual Studio team and get back to you.

Thanks for being persistant and sorry about the wait!






Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Mike Cook - MSFT

Hi again,

I checked with Visual Studio and they confirm that this was fixed post Beta2. For now you'll want to use your known workaround.

-Mike






Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

CommonGenius.com

I would just like to point out that this was NOT fixed for RTM. I installed Visual C# 2008 Express today, and tried to open the DataBinding sample, and had this exact same problem. Fortunately the workaround worked.

I have had the IDE open for a couple of hours and have encountered nothing but problems, including a hard crash. Frankly its embarassing that Microsoft released this in the state that it is in. I thought I couldn't be any more underwhelmed by a MS IDE release than I was with Visual Studio 2005; looks like I was wrong.






Re: Windows Presentation Foundation (WPF) Cannot locate resource 'window1.xaml'

Jeremiah Morrill

I have had this issue quite a bit. For me, all it took was in VS, I went to the "Build -> Clean Solution" then recompiled and ran and everything was fine. Fixed it every single time I had this problem.

Hope the fix is that easy for you.