Trường Giang
Trường Giang

Reputation: 1

System.IO.IOException: 'Cannot locate resource 'mainwindow.xaml'.'

I run a page-style application

<Page x:Class="WpfApp1.Page1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:local="clr-namespace:WpfApp1"
  mc:Ignorable="d" 
  d:DesignHeight="450" d:DesignWidth="800"
  Title="Page1">
<Page.Resources>
  ......
</Page>

The error message is as follows:

System.IO.IOException: 'Cannot locate resource 'mainwindow.xaml'.'

Any idea what's going on?

Upvotes: 0

Views: 3705

Answers (2)

Bola Gadalla
Bola Gadalla

Reputation: 400

You probably moved the page into a folder so maybe you created a folder called Views for example and you moved that page into it. So you go to the App.xaml and located the StartupUri and in the startup you put "/Views/Page1.xaml" so that should all be in one line like:

StartupUri="/Views/Page1.xaml"

Upvotes: 1

Akarsha
Akarsha

Reputation: 191

Edit startupUri in App.xaml file. In your case you mentioned you're running a page style application, so i assume "WpfApp1.Page1" is the startup page, so StartupUri="WpfApp1/Page1.xaml"

Upvotes: 1

Related Questions