So, I wanted to rename a window in a WPF application - a prototype I’m working on.

First, I rename the code in the .cs code-behind file. Then, I change the Class attribute on the root element of the xaml file.

Cool, thinks I. A quick compile, no errors, everything looks good.

But, when the application is run … I got an error dialog saying “There is no source code available for the current location”:

WPF Error

Eh? I thought the technology was called WPF, not WTF!

The exception dialog that followed wasn’t much help either: “Cannot locate resource window1.xaml”:

WPF Error

But, thought I - I’ve already changed all the references to window1.xaml … haven’t I?

After some searching with Google and pulling of hair, I found the culprit - in my App.xaml file:

<Application 
    x:Class="PocDemoA.App"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     StartupUri="Window1.xaml">
    <Application.Resources>
 
    </Application.Resources>
</Application>

The StartupUri setting that needed to be updated to the new name of my form.

<Application 
    x:Class="PocDemoA.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="Controller.xaml">
    <Application.Resources>
 
    </Application.Resources>
</Application>

One Problem solved, a thousand more to go.

Comments

blog comments powered by Disqus
Next Post
Conditional Compilation  09 Apr 2008
Prior Post
Open for Comments  06 Apr 2008
Related Posts
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
When are you done?  18 Apr 2022
Fixing GitHub Authentication  28 Nov 2021
Archives
April 2008
2008