jxbma
asked on
How do I resolve a "Cannot locate resource" exception thrown when loading a WPF user control from a WPF Class Library?
Hi:
I'm a newbie at the world of WPF.
As a starting point/exercise, I've taken an existing WPF app (with subsequent customized controls) and
converted it to a class library. The library (dll) build without an warning/error messages.
I've trying to embed a control from the class library inside a window/control in my .Net winforms application.
I'm using the ElementHost control . The goal is to host the WPF control within the ElementHost control.
This piece compiles and looks fine.
However when I run my application, I get the following exception:
========================== ========== =====
"'Set property 'System.Windows.ResourceDi ctionary.S ource' threw an exception.' Line number '15' and line position '18'." string
Systeim.IO.IOException --> "Cannot locate resource 'dictionaries/brushes.xaml '." string
The Class Library contains a couple of xaml resources that are shared amongst the WPF controls.
They are part of the Class Library's VS solution/project. I'm assuming that they get built into
the Class Library/DLL, otherwise my Class Library would not build.
I noticed that the "Exe" version had an "App.xaml" file which had the following section defined:
========================== ========== ========== ========== ===
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.Merged Dictionari es>
<ResourceDictionary Source="ResourceDictionari es/Brushes .xaml" />
. . .
</ResourceDictionary.Merge dDictionar ies>
</ResourceDictionary>
</Application.Resources>
What am I missing here?
Does the Class Library contain some sort of similar definition/construct?
Any help would be greatly appreciated, as I'm trying to throw together a quick demo and have already been working on this issue for several hours.
Thanks in advance,
JohnB
I'm a newbie at the world of WPF.
As a starting point/exercise, I've taken an existing WPF app (with subsequent customized controls) and
converted it to a class library. The library (dll) build without an warning/error messages.
I've trying to embed a control from the class library inside a window/control in my .Net winforms application.
I'm using the ElementHost control . The goal is to host the WPF control within the ElementHost control.
This piece compiles and looks fine.
However when I run my application, I get the following exception:
==========================
"'Set property 'System.Windows.ResourceDi
Systeim.IO.IOException --> "Cannot locate resource 'dictionaries/brushes.xaml
The Class Library contains a couple of xaml resources that are shared amongst the WPF controls.
They are part of the Class Library's VS solution/project. I'm assuming that they get built into
the Class Library/DLL, otherwise my Class Library would not build.
I noticed that the "Exe" version had an "App.xaml" file which had the following section defined:
==========================
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.Merged
<ResourceDictionary Source="ResourceDictionari
. . .
</ResourceDictionary.Merge
</ResourceDictionary>
</Application.Resources>
What am I missing here?
Does the Class Library contain some sort of similar definition/construct?
Any help would be greatly appreciated, as I'm trying to throw together a quick demo and have already been working on this issue for several hours.
Thanks in advance,
JohnB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the advise!
JB