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.ResourceDictionary.Source' 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.MergedDictionaries>
              <ResourceDictionary Source="ResourceDictionaries/Brushes.xaml" />
               . . .

       </ResourceDictionary.MergedDictionaries>
    </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
LVL 1
jxbmaSoftware ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jxbmaSoftware ConsultantAuthor Commented:
Ultimately, after some refactoring, this solution worked.

Thanks for the advise!
JB
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.