6

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

4
  • 1
    Can you confirm, that the requested library is included in the output folder, when you run the application? Commented Aug 25, 2014 at 14:58
  • 1
    Yes, the output folder of the Class Library project does contain the needed .dll (WpfCustomControlLibrary.dll). Commented Aug 26, 2014 at 15:06
  • 1
    There are known issues with this, for a dirty solution, add the WpfCustomControlLibrary.dll to executable output folder, maybe someone will come up with detailed explanation, basically there is a problem with locating the resources for custom control. Commented Aug 27, 2014 at 14:18
  • 1
    @Novitchi S So what you are saying is that this is a confirmed bug? Either way, thanks a lot, this actually solved the problem! What I did exactly was adding the reference of the CustomControlLibrary to the AddIn project. Commented Aug 28, 2014 at 11:26

1 Answer 1

1

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"
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @Jams, unfortunately since this problem occured some time back, I don't have access to the code anymore. Thanks for your reply nevertheless!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.