C#C
C#2y ago
18 replies
stigzler

Visual Studio + WPF: "Could Not Load Assembly" despite dlls being available and reference correct

This has been driving me nuts for a day now. It's an intermittent error as had this working fine at one point. I'm designing a WPF UserControl. This depends on a third party library that I download from nuget ([here]{https://www.nuget.org/packages/Wpf.Controls.PanAndZoom/2.3.4)

It installs fine. I can also reference it in my UserControl at the top without any errors:

 xmlns:paz="clr-namespace:Wpf.Controls.PanAndZoom;assembly=Wpf.Controls.PanAndZoom"

However, when I try to use the control via this:

<paz:ZoomBorder Background="CornflowerBlue"></paz:ZoomBorder>

Intellisense give me the attached error.

It also shows as an Error:
XDG0003    Could not load file or assembly 'Wpf.Controls.PanAndZoom, Version=2.3.4.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.    stigzler.Workspace    C:\Users\stigz\source\repos\0.MyCode\CS\Framework\stigzler.WpfWorkspace\stigzler.Workspace\Workspace.xaml    12

Weird thing is it compiles, but then I can't use it in a test WPF App that references the control. Again it compiles fine, but at runtime, I get the exception:

System.Windows.Markup.XamlParseException: 'Could not load file or assembly 'Wpf.Controls.PanAndZoom, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.'


It's doing my head in because this library worked fine at one point - it feels very intermittent and random.

Here's what I've tired:
1. Full Clean and Rebuild of Library
2. Deleted the vs folders in the solution
3. Uninstalled and re-installed the third party library after above
Screenshot_2024-04-02_101620.png
Was this page helpful?