John
John

Reputation: 175

Could not load file or assembly NLog

Error: http://pbrd.co/1vTqOTb

I am getting an error in my XAML in my WPF project:

"Error  11  Could not load file or assembly 'NLog, Version=2.0.0.0, 
 Culture=neutral, PublicKeyToken=5120e14c03d0593c' or one of its dependencies. 
 The system cannot find the file specified. MainWindow.xaml 73  9   TestApp"

I have searched the entire solution and cant find any 'NLog' I have tried to add the NLog dll to each of my projects in the solution but it makes no difference. Any idea?

Upvotes: 3

Views: 11025

Answers (2)

John
John

Reputation: 175

Turned out to be the NLog was .Net 4.0 and the project was .Net 4.5 I changed the project to 4.0 and the other dependent project to 4.0 and its working. Thanks!

Upvotes: 5

David
David

Reputation: 10708

Whenever you reference another library, there's the chance they will need some other library. When you reference WPF, there are a lot of underlying libraries that get pulled up.

First, make sure that the DLLs you've referenced are set to "Copy Local = True" under their Properties. Also make sure they have the same PublicKeyToken as your error - if they're referenced by strong name (and most of .NET is) a slightly different version won't be read as the correct file.

The other thing you should consider is checking whether the DLL exists in your GAC, and manually installing it if it doesn't. This can often be the cause of such frustrating errors due to a misinstalled sdk (I once has the same issue with the Blend libraries)

Upvotes: 2

Related Questions