Hey gang!
I'm trying to build an Excel-DNA add-in, with WPF support. I have the WPF functionality working, using the WinForms host component, and it's working fine as long as everything is held into the one project.
I have a separate assembly holding some common WPF component types (MyControls), and another NuGet package that holds more WPF component types (NuGetPackage). In the central add-in project (MyAddIn), I'm referencing the two separate assemblies using dependencies, and in the .csproj file I have `<ExcelAddInInclude>MyControls.dll;NuGetPackage.dll</ExcelAddInInclude>`
In order to reference all of the resources built, I have a resource dictionary built in MyAddIn/Content/AppResources.xaml. It's just composed of the following:
<ResourceDictionary xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<!-- App-wide resource dictionary for themes, content, styles, etc. -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MyControls;component/Resources/Default.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
MyControls/Resources/Default.xaml is just another merged resource dictionary that compiles all of the resources I want to expose to my main application.
Then, when I build a Custom Task Pane to display WPF controls building off of the common controls library, I run the following code:
public static CustomPane CreateCustomTaskPane(UserControl component, string title) {
var dict = new ResourceDictionary() { Source = new Uri("Content/AppResources.xaml", UriKind.Relative) };
component.Resources.MergedDictionaries.Add(dict);
// etc., build the component out and add it to the WinForms host component.
}
In the line trying to build the above ResourceDictionary, I get the following error informing me that it has an error while loading the Content/AppResources.xaml file - specifically that it can't find the `MyControls` assembly:
FileNotFoundException: Could not load file or assembly 'MyControls, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
I'm seeing that the MyControls.dll is successfully being exported and sent next to the .xll output file. I've tried a few other things - such as setting Application.ResourceAssembly = Assembly.GetExecutingAssembly(), only building the ResourceDictionary once and assigning it to any newly created component - but nothing has given me any success yet.
If I need to give any further information, please let me know! Thank you!