Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a library that has ResourceDictionary's in it so they can be reused. In this library I also have other classes that are WPF related, such as extended methods etc.

I have a control that is inheriting from TabControl in the library. I want to be able to access the Resource Dictionaries but it isn't an application.

Below is what I have tried. I get 'Initialization of 'System.Windows.Setter' threw an exception.'

One file is in the /Controls directory and the other is in the /Layout directory both directories are at the same level.

ResourceDictionary resource = new ResourceDictionary
           {
               Source = new Uri("/BPCWPFUtilities;component/Layout/WPFBasicLayout.xaml", UriKind.RelativeOrAbsolute)
           };
           //                Source = new Uri("pack://application:,,,/BPCWPFUtilities;component/Layout/WPFBasicLayout.xaml", UriKind.RelativeOrAbsolute)
Posted
Comments
Sergey Alexandrovich Kryukov 22-Aug-13 12:57pm    
In which line?
And please understand, you reference not "DLL", but assembly? Even though the reference can mention DLL module, this is not what is referenced. Do you know the difference?
—SA
bowlturner 22-Aug-13 14:11pm    
The files are in the same project. The project has a DLL as an output, not an application. That is what I was trying to convey.

Both lines give me the same error. I'm just wondering what would be the correct uri to put in there in this situation. The commented out line has the URI that works for my app that uses the DLL so I didn't have a lot of hope there but tried it anyway.
Sergey Alexandrovich Kryukov 22-Aug-13 17:53pm    
A DLL or application, still an assembly. .NET does not make essential difference.
Error or exception? What "both lines", exactly?
—SA
bowlturner 23-Aug-13 9:11am    
So this is all in one assembly.

Throws the exception I listed above.

'System.Windows.Setter' threw an exception.'

I also used the the commented out line in place of the "Source = new..."

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900