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:
However, when I try to use the control via this:
Intellisense give me the attached error.
It also shows as an Error:
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:
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
6 Replies
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)
Does the app itself compile?
The WPF designer is bad.
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
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
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
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...