Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



WPF Gotcha: Cannot locate Resource "FileName.xaml"

Today I was working with a WPF project and when I went to run the application I got the following error 'Cannot locate resource 'FileName.xaml'.  Note, this is NOT a compiler error, this is a runtime error.

When I opened up the App.xaml file, the StartupUri appeared to be correct, but I would still get this error.  After playing around for a few minutes it dawned on me what the issue is.

Let me explain:

In my project I created a subfolder to put my views (forms) into.  I named this folder 'Views'.  Example:
-> Root
     -> Views
          -> FileName.xaml

Turns out that in order for the StartupUri to find the xaml form, you need to provide the file path of the file, not name the namespace path of the file.  When I did that it all worked.

None Working StartupUri
StartupUri="FileName.xaml"

Working StartupUri
StartupUri="Views/LayoutEditor.xaml"

Hope this helps

Till next time


kick it on DotNetKicks.com

Published Aug 05 2007, 09:56 AM by Derik Whittaker
Filed under: , , ,

Comments

Cornel said:

Helped. Thanks a lot

# May 2, 2008 9:29 AM

jcvasquezt said:

dude, you rock I've been looking for this for a while.

thanks a lot.

# June 4, 2008 6:19 PM

Suraj Mehare said:

your suggestion helped me solve the exact problem, thanks a lot

# November 13, 2008 6:58 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News