Vs2017: An Error Occured while finding the resource dictionary - wpf

Am getting the below error when i tried to refer the resource dictionary my app.xaml file
<Application x:Class="DesignerPoc.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DesignerPoc"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Dashboard.Designer.WPF;Connection/Views/test.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Error
An Error occurred while finding the resource dictionary "pack://application:,,,/Dashboard.Designer.WPF;Connection/Views/test.xaml"
refer the image
How to resolve this.??

Your Resource File Pack URI is wrong.
It should look like this, including the component part:
pack://application:,,,/Dashboard.Designer.WPF;component/Connection/Views/test.xaml

Related

How to change just one merged resource dictionary in WPF?

Our application uses a ResourceDictionary for its styles. This resource dictionary itself contains resource dictionaries thus:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="BridgeIt5/General.xaml" />
<ResourceDictionary Source="BridgeIt5/Brushes.xaml" />
<ResourceDictionary Source="BridgeIt5/Constants.xaml" />
<ResourceDictionary Source="BridgeIt5/Button.xaml" />
...
</ResourceDictionary.MergedDictionaries>
So, now depending on the build configuration we just want to change the Brushes.xaml merged resource dictionary. How can this be done?
If you can set the configuration at runtime you can do this during startup:
var resourceDictionary = new ResourceDictionary
{
// Pick uri from configuration
Source = new Uri("BridgeIt5/Brushes.xaml"),
};
Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);

Cannot locate resource 'themes/style/master.xaml'

Here is my Solution explorer:
I want to make this:
ResourceDictionary dictionary = new ResourceDictionary();
dictionary.Source = new Uri("../Themes/Generic.xaml", UriKind.RelativeOrAbsolute);
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary());
in the constructor of PageWithoutMaster.
I get error: Cannot locate resource 'themes/style/master.xaml'
What am I doing wrong? Why is it adding the style folder in the path?
As dkozl pointed out, you can fix this by using a Pack URI and including the assembly name in your path
Assuming your resource file looks something like this:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp4.Themes">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Style/Master.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Get your assembly name from your project properties:
Then update to this value instead:
<ResourceDictionary Source="WpfApp4;component/Style/Master.xaml" />

VS2013: An error occurred while finding the resource dictionary

I just got VS2013 and opened my VS2010 project. However now I cannot see any of xaml designs. The problem is the Styles are not being applied:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Colors.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Gives me the error:
Error 1 An error occurred while finding the resource dictionary "/Themes/Colors.xaml".
This works fine in VS2010. The build option is set to Page. All target frameworks are set to .NET 4.
The directory structure is this:
Host\Themes\Colors.xaml
Plugins\EqPlugin\Source\ProblemFile.xaml
The themes are defined in the VEParameters project and have this declared:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EQPlugin;assembly=VEParameterTool">
The file where the error occurs is in the EqPlugIn directory and has this declared:
<UserControl x:Class="EQPlugin.EQControl"
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:src="clr-namespace:VEParameterTool;assembly=VEParameterTool"
xmlns:l="clr-namespace:EQPlugin"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:oxy="http://oxyplot.codeplex.com"
mc:Ignorable="d">
I have tried changing the paths to relative paths but that doesn't work, i have removed and re-added the assemblies, i have restarted etc, all projects are build for the same framework. I don't know what else to try.
Try the below one, Provied the assembly name, even if it is in the same assembly
Source="pack://application:,,,/<assemblyName>;component/Themes/Colors.xaml"

The type or namespace name could not be found (are you missing a using directive or an assembly reference

I have Downloaded one project from internet when tried to include to my main project It is showing Clr namespace Error Please help me I have already added dll file in reference what should i do ?? Its showing error in SiriusMicrotech clr namespace..
//My Coding//
<Page x:Class="RTBSPROJECT.Point_Of_Sale.Invoice"
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:ig="http://schemas.infragistics.com/xaml"
xmlns:SiriusMicrotech="clr-namespace:SiriusMicrotech.core.UI"
mc:Ignorable="d"
Title="Invoice" >
enter code here
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Point Of Sale\TouchStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</page.Resources>
Hi you also need to specify the Assembly along with namespace when you use assembly other than current assembly
xmlns:SiriusMicrotech="clrnamespace:SiriusMicrotech.core.UI;assembly=AssemblyName....."
I hope this will help.

Unknown parser error when try to add resources

I have problem with adding resources to my wp7 project.
I have added
<resources:LocalizedStrings x:Key="LocalizedStrings"/>
and after running application I recieve such XamlParseException: Unknown parser error: Scanner 2147500037.
Here is code.
<Application
x:Class="MyProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:vm="clr-namespace:MyProject.ViewModels;assembly=MyProject.ViewModels"
xmlns:resources="clr-namespace:MyProject.Resources;assembly=MyProject.Resources">
<Application.Resources>
<ResourceDictionary>
<resources:LocalizedStrings x:Key="LocalizedStrings"/>
<vm:ViewModelLocator x:Key="Locator"/>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="styles/globalstyles.xaml"/>
<ResourceDictionary Source="styles/UserStyles.xaml"/>
<ResourceDictionary Source="styles/DialogStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects></Application>
Resolve this issue by creating project MyProject.LocalizedResources instead of MyProject.Resources
xmlns:resources="clr-namespace:MyProject.LocalizedResources;assembly=MyProject.LocalizedResources"
This works well now.
Single word Resources in project name leads to the error! :(

Resources