IOException: 'Cannot locate resource' in Visual Studio
up vote
0
down vote
favorite
I have a WPF program, with a main window, which utilizes some resource dictionaries, located in a subfolder, as you can see here (we will soon get to, why I highlighted one of them):
In the top of my MainWindow.xaml, I include some of these resource dictionaries, like this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/XamlResources/ControlTemplates.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/TextBlockStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
So obviously everything is as it should be, and the program does compile and run just fine. No exceptions, no warnings, all is good. Except it's not. Because in the Visual Studio Editor, this is what the design window shows:
Why do I get this error, when everything apparently is as it should be? I have event tried using the "Find" feature to search for other occurrences of controltemplate.xaml, but I only find valid references. Is this some sort of Visual Studio bug, and if so, how do I fix it?
UPDATE
Fiddling around with the XAML (for instance changing the way the source is formatted) sometimes causes the error to change to an SqlException, like this:
I have no idea why this happens, or why the exception seems to change from time to time. I am using Entity Framework, if that could be the root cause, but I do not have a local SQL server installed. However, this hasn't been a problem in previous projects.
c# wpf visual-studio xaml visual-studio-2017
add a comment |
up vote
0
down vote
favorite
I have a WPF program, with a main window, which utilizes some resource dictionaries, located in a subfolder, as you can see here (we will soon get to, why I highlighted one of them):
In the top of my MainWindow.xaml, I include some of these resource dictionaries, like this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/XamlResources/ControlTemplates.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/TextBlockStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
So obviously everything is as it should be, and the program does compile and run just fine. No exceptions, no warnings, all is good. Except it's not. Because in the Visual Studio Editor, this is what the design window shows:
Why do I get this error, when everything apparently is as it should be? I have event tried using the "Find" feature to search for other occurrences of controltemplate.xaml, but I only find valid references. Is this some sort of Visual Studio bug, and if so, how do I fix it?
UPDATE
Fiddling around with the XAML (for instance changing the way the source is formatted) sometimes causes the error to change to an SqlException, like this:
I have no idea why this happens, or why the exception seems to change from time to time. I am using Entity Framework, if that could be the root cause, but I do not have a local SQL server installed. However, this hasn't been a problem in previous projects.
c# wpf visual-studio xaml visual-studio-2017
Did you try <ResourceDictionary Source="XamlResources/ControlTemplates.xaml" />?
– Kaspar
Nov 21 at 13:44
@Kaspar I have tried that. It doesn't change a whole lot. However, sometime the error changes to an XamlParseException instead. It still states though, that i cannot locate resourcexamlresource/controltemplates.xaml
.
– Noceo
Nov 21 at 13:53
Have you checked the encoding of the file? I've had in the past the encoding being changed from utf-8 to utf-8 with signature which Visual Studio dislikes.
– Coops
Nov 21 at 15:08
@Coops not sure how to check that. I haven't changed the encoding (at least not on purpose), also wouldn't that break the program entirely?
– Noceo
Nov 23 at 10:38
Open the file in Notepad++ and there's an encoding menu, just check that it's utf-8 and not utf-8 signed.
– Coops
Nov 23 at 10:40
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a WPF program, with a main window, which utilizes some resource dictionaries, located in a subfolder, as you can see here (we will soon get to, why I highlighted one of them):
In the top of my MainWindow.xaml, I include some of these resource dictionaries, like this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/XamlResources/ControlTemplates.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/TextBlockStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
So obviously everything is as it should be, and the program does compile and run just fine. No exceptions, no warnings, all is good. Except it's not. Because in the Visual Studio Editor, this is what the design window shows:
Why do I get this error, when everything apparently is as it should be? I have event tried using the "Find" feature to search for other occurrences of controltemplate.xaml, but I only find valid references. Is this some sort of Visual Studio bug, and if so, how do I fix it?
UPDATE
Fiddling around with the XAML (for instance changing the way the source is formatted) sometimes causes the error to change to an SqlException, like this:
I have no idea why this happens, or why the exception seems to change from time to time. I am using Entity Framework, if that could be the root cause, but I do not have a local SQL server installed. However, this hasn't been a problem in previous projects.
c# wpf visual-studio xaml visual-studio-2017
I have a WPF program, with a main window, which utilizes some resource dictionaries, located in a subfolder, as you can see here (we will soon get to, why I highlighted one of them):
In the top of my MainWindow.xaml, I include some of these resource dictionaries, like this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/XamlResources/ControlTemplates.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/TextBlockStyles.xaml" />
<ResourceDictionary Source="pack://application:,,,/XamlResources/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
So obviously everything is as it should be, and the program does compile and run just fine. No exceptions, no warnings, all is good. Except it's not. Because in the Visual Studio Editor, this is what the design window shows:
Why do I get this error, when everything apparently is as it should be? I have event tried using the "Find" feature to search for other occurrences of controltemplate.xaml, but I only find valid references. Is this some sort of Visual Studio bug, and if so, how do I fix it?
UPDATE
Fiddling around with the XAML (for instance changing the way the source is formatted) sometimes causes the error to change to an SqlException, like this:
I have no idea why this happens, or why the exception seems to change from time to time. I am using Entity Framework, if that could be the root cause, but I do not have a local SQL server installed. However, this hasn't been a problem in previous projects.
c# wpf visual-studio xaml visual-studio-2017
c# wpf visual-studio xaml visual-studio-2017
edited Nov 21 at 14:17
asked Nov 21 at 13:29
Noceo
9751331
9751331
Did you try <ResourceDictionary Source="XamlResources/ControlTemplates.xaml" />?
– Kaspar
Nov 21 at 13:44
@Kaspar I have tried that. It doesn't change a whole lot. However, sometime the error changes to an XamlParseException instead. It still states though, that i cannot locate resourcexamlresource/controltemplates.xaml
.
– Noceo
Nov 21 at 13:53
Have you checked the encoding of the file? I've had in the past the encoding being changed from utf-8 to utf-8 with signature which Visual Studio dislikes.
– Coops
Nov 21 at 15:08
@Coops not sure how to check that. I haven't changed the encoding (at least not on purpose), also wouldn't that break the program entirely?
– Noceo
Nov 23 at 10:38
Open the file in Notepad++ and there's an encoding menu, just check that it's utf-8 and not utf-8 signed.
– Coops
Nov 23 at 10:40
add a comment |
Did you try <ResourceDictionary Source="XamlResources/ControlTemplates.xaml" />?
– Kaspar
Nov 21 at 13:44
@Kaspar I have tried that. It doesn't change a whole lot. However, sometime the error changes to an XamlParseException instead. It still states though, that i cannot locate resourcexamlresource/controltemplates.xaml
.
– Noceo
Nov 21 at 13:53
Have you checked the encoding of the file? I've had in the past the encoding being changed from utf-8 to utf-8 with signature which Visual Studio dislikes.
– Coops
Nov 21 at 15:08
@Coops not sure how to check that. I haven't changed the encoding (at least not on purpose), also wouldn't that break the program entirely?
– Noceo
Nov 23 at 10:38
Open the file in Notepad++ and there's an encoding menu, just check that it's utf-8 and not utf-8 signed.
– Coops
Nov 23 at 10:40
Did you try <ResourceDictionary Source="XamlResources/ControlTemplates.xaml" />?
– Kaspar
Nov 21 at 13:44
Did you try <ResourceDictionary Source="XamlResources/ControlTemplates.xaml" />?
– Kaspar
Nov 21 at 13:44
@Kaspar I have tried that. It doesn't change a whole lot. However, sometime the error changes to an XamlParseException instead. It still states though, that i cannot locate resource
xamlresource/controltemplates.xaml
.– Noceo
Nov 21 at 13:53
@Kaspar I have tried that. It doesn't change a whole lot. However, sometime the error changes to an XamlParseException instead. It still states though, that i cannot locate resource
xamlresource/controltemplates.xaml
.– Noceo
Nov 21 at 13:53
Have you checked the encoding of the file? I've had in the past the encoding being changed from utf-8 to utf-8 with signature which Visual Studio dislikes.
– Coops
Nov 21 at 15:08
Have you checked the encoding of the file? I've had in the past the encoding being changed from utf-8 to utf-8 with signature which Visual Studio dislikes.
– Coops
Nov 21 at 15:08
@Coops not sure how to check that. I haven't changed the encoding (at least not on purpose), also wouldn't that break the program entirely?
– Noceo
Nov 23 at 10:38
@Coops not sure how to check that. I haven't changed the encoding (at least not on purpose), also wouldn't that break the program entirely?
– Noceo
Nov 23 at 10:38
Open the file in Notepad++ and there's an encoding menu, just check that it's utf-8 and not utf-8 signed.
– Coops
Nov 23 at 10:40
Open the file in Notepad++ and there's an encoding menu, just check that it's utf-8 and not utf-8 signed.
– Coops
Nov 23 at 10:40
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
We have a similar setup in our application and use this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Your.Assembly.Name;component/XamlResources/TextBlockStyles.xaml" />
<!-- ... -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Fun stuff. If I make this changes, the designer displays the actual window (and content) for like a second, before then throwing a new exception, this time anSqlException
(still at design time, no compiling or running the program).
– Noceo
Nov 21 at 14:13
@Noceo I wouldn't worry about on the designer preview too much, it's pretty finicky and often doesn't work although a control or window works when actually run. However the SqlException hints that loading of the styles now works and it has run in new issues in displaying data from your controls.
– Lennart
Nov 21 at 14:18
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
We have a similar setup in our application and use this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Your.Assembly.Name;component/XamlResources/TextBlockStyles.xaml" />
<!-- ... -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Fun stuff. If I make this changes, the designer displays the actual window (and content) for like a second, before then throwing a new exception, this time anSqlException
(still at design time, no compiling or running the program).
– Noceo
Nov 21 at 14:13
@Noceo I wouldn't worry about on the designer preview too much, it's pretty finicky and often doesn't work although a control or window works when actually run. However the SqlException hints that loading of the styles now works and it has run in new issues in displaying data from your controls.
– Lennart
Nov 21 at 14:18
add a comment |
up vote
0
down vote
We have a similar setup in our application and use this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Your.Assembly.Name;component/XamlResources/TextBlockStyles.xaml" />
<!-- ... -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Fun stuff. If I make this changes, the designer displays the actual window (and content) for like a second, before then throwing a new exception, this time anSqlException
(still at design time, no compiling or running the program).
– Noceo
Nov 21 at 14:13
@Noceo I wouldn't worry about on the designer preview too much, it's pretty finicky and often doesn't work although a control or window works when actually run. However the SqlException hints that loading of the styles now works and it has run in new issues in displaying data from your controls.
– Lennart
Nov 21 at 14:18
add a comment |
up vote
0
down vote
up vote
0
down vote
We have a similar setup in our application and use this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Your.Assembly.Name;component/XamlResources/TextBlockStyles.xaml" />
<!-- ... -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
We have a similar setup in our application and use this:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Your.Assembly.Name;component/XamlResources/TextBlockStyles.xaml" />
<!-- ... -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
answered Nov 21 at 14:01
Lennart
5,935124965
5,935124965
Fun stuff. If I make this changes, the designer displays the actual window (and content) for like a second, before then throwing a new exception, this time anSqlException
(still at design time, no compiling or running the program).
– Noceo
Nov 21 at 14:13
@Noceo I wouldn't worry about on the designer preview too much, it's pretty finicky and often doesn't work although a control or window works when actually run. However the SqlException hints that loading of the styles now works and it has run in new issues in displaying data from your controls.
– Lennart
Nov 21 at 14:18
add a comment |
Fun stuff. If I make this changes, the designer displays the actual window (and content) for like a second, before then throwing a new exception, this time anSqlException
(still at design time, no compiling or running the program).
– Noceo
Nov 21 at 14:13
@Noceo I wouldn't worry about on the designer preview too much, it's pretty finicky and often doesn't work although a control or window works when actually run. However the SqlException hints that loading of the styles now works and it has run in new issues in displaying data from your controls.
– Lennart
Nov 21 at 14:18
Fun stuff. If I make this changes, the designer displays the actual window (and content) for like a second, before then throwing a new exception, this time an
SqlException
(still at design time, no compiling or running the program).– Noceo
Nov 21 at 14:13
Fun stuff. If I make this changes, the designer displays the actual window (and content) for like a second, before then throwing a new exception, this time an
SqlException
(still at design time, no compiling or running the program).– Noceo
Nov 21 at 14:13
@Noceo I wouldn't worry about on the designer preview too much, it's pretty finicky and often doesn't work although a control or window works when actually run. However the SqlException hints that loading of the styles now works and it has run in new issues in displaying data from your controls.
– Lennart
Nov 21 at 14:18
@Noceo I wouldn't worry about on the designer preview too much, it's pretty finicky and often doesn't work although a control or window works when actually run. However the SqlException hints that loading of the styles now works and it has run in new issues in displaying data from your controls.
– Lennart
Nov 21 at 14:18
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413142%2fioexception-cannot-locate-resource-in-visual-studio%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you try <ResourceDictionary Source="XamlResources/ControlTemplates.xaml" />?
– Kaspar
Nov 21 at 13:44
@Kaspar I have tried that. It doesn't change a whole lot. However, sometime the error changes to an XamlParseException instead. It still states though, that i cannot locate resource
xamlresource/controltemplates.xaml
.– Noceo
Nov 21 at 13:53
Have you checked the encoding of the file? I've had in the past the encoding being changed from utf-8 to utf-8 with signature which Visual Studio dislikes.
– Coops
Nov 21 at 15:08
@Coops not sure how to check that. I haven't changed the encoding (at least not on purpose), also wouldn't that break the program entirely?
– Noceo
Nov 23 at 10:38
Open the file in Notepad++ and there's an encoding menu, just check that it's utf-8 and not utf-8 signed.
– Coops
Nov 23 at 10:40