Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not load file or assembly" Exception when using a Wpf Custom Control in C#

I'm trying to create and use a WPF Custom Control within a WPF Window. The Window is defined in a Class Library Project and used in an Office Word AddIn Project, while the Custom Control is defined in a Wpf Custom Control Library Project.

There aren't any errors before the project is started, the corresponding classes are also suggested by code completion.

The actual problem occurs in the Constructor of the Wpf Window, where the InitializeComponent() method throws an Exception with the following information:

"A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Could not load file or assembly 'WpfCustomControlLibrary, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."

This behaviour occurs regardless of the content of the mentioned classes, I have tried this with the most basic code possible. I also tried to create the Wpf Window right in the AddIn Project, using just the Wpf Custom Control Library Project (no separate Class Library). Although this scenario works just fine, I would very much appreciate to keep the separate Class Library for structural purposes.

Any help is highly appreciated, if further information is needed just let me know.

Kind regards

like image 879
Wbes Avatar asked Aug 25 '14 11:08

Wbes


1 Answers

Did you try to specify the assembly where your custom control is defined using the following syntax:

 xmlns:export="clr-namespace:your.custom.control.namespace;assembly=your.assembly.name"
like image 187
Jams Avatar answered Oct 25 '22 11:10

Jams