- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In a test project I am working on I am trying to use the FontAwesome.WPF NuGet package for icons to be displayed on a palette control. Here is the current solution structure
Solution
- Core.csproj (references UI.csproj for views)
- UI.csproj (the project that references the FontAwesome.WPF package)
In the WPF UserControl that needs the icons I have added the namespace declaration and usage of the icons like this
xmlns:fa="http://schemas.fontawesome.io/icons/"
...
<fa:ImageAwesome
Icon="Plus"
Width="16" Height="16"
Margin="0 0 5 0"/>
<TextBlock Text="Connect To Existing Project" />
Everything in the XAML designer renders fine. However, when I NETLOAD my plugin from bin/Debug/Core.dll and then trigger the command that shows my palette with the icons I get the following error at the InitializeComponent method in the code-behind my user control
System.Windows.Markup.XamlParseException
HResult=0x80131501
Message=Could not load file or assembly 'FontAwesome.WPF, PublicKeyToken=0758b07a11a4f466' or one of its dependencies. The system cannot find the file specified.
Source=PresentationFramework
StackTrace:
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at UI.View.ProjectTabView.InitializeComponent() in C:\Users\jerem\source\repos\PluginUIDemo\UI\View\ProjectTabView.xaml:line 1
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'FontAwesome.WPF, PublicKeyToken=0758b07a11a4f466' or one of its dependencies. The system cannot find the file specified.
Now the part where I get really confused is that I have confirmed that the FontAwesome.WPF.dll is present in my output directory (bin/Debug/FontAwesome.WPF.dll). I also am referencing a MVVM NuGet package in UI.csproj in the same way and that works just fine (however the difference is this isn't being loaded during initialization of a user control).
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm">
<Version>8.3.2</Version>
</PackageReference>
<PackageReference Include="FontAwesome.WPF">
<Version>4.7.0.9</Version>
</PackageReference>
</ItemGroup>
Interestingly, I can fix this error by manually copying the FontAwesome.WPF.dll into the C:\Program Files\Autodesk\AutoCAD 2024 directory, which confirms that is where ACAD is looking for this package. What I don't understand is why ACAD is looking for this package in the program files directory (C:\Program Files\Autodesk\AutoCAD 2024) and not in the bin/Debug output directory where I indicated that my plugin dll is and all the other dlls that mine depends on are located. Is there something different about loading assemblies for user controls?
Solved! Go to Solution.