C
C#9mo ago
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"
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>
<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
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.'
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
No description
6 Replies
stigzler
stigzlerOP9mo ago
OK. Narrowed it down. When I compile the User Control, the debug folder has the UserContorl dll + the third party dll + it's own dependencies (it relies on two other dlls) When I reference it in another project, only the User Control dll gets copied to that project - not the third party dll or its own dependencies. What am I missing here? CopyLocal = true in both projects (urgh @ WPF)
RazorSharpFang
RazorSharpFang9mo ago
Does the app itself compile? The WPF designer is bad.
stigzler
stigzlerOP9mo ago
Yes, but it fails at runtime with the above error OK - just started a new solution (for the 10th time) and this time it's worked god, WPF and VS together are a fing nightmare Nope - it's back. God I hate WPF OK - if I start a new project and use the default user control, then it works. If I delete that and then AddItem>WPFUserControl, it stops copying the dependencies (despite the 'stock' user control doing so). Think I'm going to take a hammer to something... Forget the above - doens't work either. Fk this
RazorSharpFang
RazorSharpFang9mo ago
Can you double-check that it is actually being copied into the target output directory? If the item exists in the visual studio solution explorer Check that it has Copy to output directory: Always
stigzler
stigzlerOP9mo ago
naw - I'm bailing to spare my sanity. I had done all that as above - the 3rd party dependencies weren't getting copied into the app dlls 2 days on this: sucks ass Even tried re-installing VS - still no dice
stigzler
stigzlerOP9mo ago
Turns out it was a 14 year old MS VS bug! Thanks MS, ffs. https://stackoverflow.com/a/8213977/3472225
Stack Overflow
Reference DLL file not copying to bin with deployment project, caus...
We have several external DLL files being referenced in our Web Application Project. We have a deployment project for installing on the hosting servers. When we were using .NET 3.5 and Visual S...
Want results from more Discord servers?
Add your server