[c#] Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies

I have this exception generated on some user machines (~1 of 20):

Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

I found several references to this error over the web and this site but nothing helped.

I have an add-in application which uses WCF to connect to the server. The add-in built with .NET Framework 3.5 with VS 2008.

The error is reproducible on one of the test machines in only one user account. I install my application and can only reproduce this from one account on this machine everywhere else it is working fine. Furthermore it is only reproducible with only one version of host application which I created add-in for (I assume because it uses differnet .NET Frameworks).

I have checked the fuse logs and I see the following:


Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files\SolidWorks Corp\SolidWorks\sldworks.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = Home\User
LOG: DisplayName = System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/SolidWorks Corp/SolidWorks/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.

So by some reasons it is trying to use v2.0.50727\mscorwks.dll loader to load the Version=4.0.0.0 of System.dll. On build machine I'm referring 2.0.0.0 version of System.dll.

This question is related to c# .net frameworks

The answer is


I had this same problem - some users could pull from git and everything ran fine. Some would pull and get a very similar exception:

Could not load file or assembly '..., Version=..., Culture=neutral, PublicKeyToken=...' or one of its dependencies. The system cannot find the file specified.

In my particular case it was AjaxMin, so the actual error looked like this but the details don't matter:

Could not load file or assembly 'AjaxMin, Version=4.95.4924.12383, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f' or one of its dependencies. The system cannot find the file specified.

It turned out to be a result of the following actions on a Solution:

  1. NuGet Package Restore was turned on for the Solution.

  2. A Project was added, and a Nuget package was installed into it (AjaxMin in this case).

  3. The Project was moved to different folder in the Solution.

  4. The Nuget package was updated to a newer version.

And slowly but surely this bug started showing up for some users.

The reason was the Solution-level packages/respositories.config kept the old Project reference, and now had a new, second entry for the moved Project. In other words it had this before the reorg:

  <repository path="..\Old\packages.config" />

And this after the reorg:

  <repository path="..\Old\packages.config" />
  <repository path="..\New\packages.config" />

So the first line now refers to a Project that, while on disk, is no longer part of my Solution.

With Nuget Package Restore on, both packages.config files were being read, which each pointed to their own list of Nuget packages and package versions. Until a Nuget package was updated to a newer version however, there weren't any conflicts.

Once a Nuget package was updated, however, only active Projects had their repositories listings updated. NuGet Package Restore chose to download just one version of the library - the first one it encountered in repositories.config, which was the older one. The compiler and IDE proceeded as though it chose the newer one. The result was a run-time exception saying the DLL was missing.

The answer obviously is to delete any lines from this file that referenced Projects that aren't in your Solution.


I got this after downgrading a project from .net 4.5 to .net 3.5.

To resolve I had to go in to the project - properties - settings window and delete all my settings, save the project, exit and restart visual studio, go back into project - properties -settings window and re-enter all my settings and their default values


I've seen this a couple times, and it is usually fixed by running a repair on .NET Framework (whichever version the application is trying to use).


I had the problem under Linux and I needed to install those. I don't know which one actually fixed the problem, but that error was gone after that:

apt-get install mono-utils mono-runtime-sgen mono-runtime-common \
                mono-runtime-boehm mono-runtime-dbg mono-xbuild

i just changed my target .net framework and it worked .in my case i changed from .net 4.7 to .net 4. Right click your solution and select properties selct properties

Click Application >> Target Framework


I answered too late but it has worked in my case.If you are facing this issue in your project please add the following line in your web.config :

<compilation  batch="false" >

This worked in my case. If you already have compilation tag in your web.config then add only batch="false" property to it.


You are using .net 4? - Maybe on the clients there is only the ".net framework 4 client profile" installed. Try to install full package!! Download here


You can enable NuGet packages and update you dlls. so that it work. or you can update the package manually by going through the package manager in your vs if u know which version you require for your solution.


In my case, I was able to find issue with ScriptManager by setting Debug=true in web.config file


This worked for me. Go to Project->Propertied->Target Frawork->Change frame work like 3.5 to 4.0


Even I have experience some more strange things, I can see there is no dll in GAC from where the dll is loading but windows > Module shows system.dll version=4.0.0.0 loaded


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to .net

You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to use Bootstrap 4 in ASP.NET Core No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Update .NET web service to use TLS 1.2 EF Core add-migration Build Failed What is the difference between .NET Core and .NET Standard Class Library project types? Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies Nuget connection attempt failed "Unable to load the service index for source" Token based authentication in Web API without any user interface

Examples related to frameworks

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Vue.js—Difference between v-model and v-bind OS X Framework Library not loaded: 'Image not found' How to get root directory in yii2 Laravel blank white screen Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies How to filter (key, value) with ng-repeat in AngularJs? Microsoft .NET 3.5 Full download Using CSS in Laravel views? Difference between framework vs Library vs IDE vs API vs SDK vs Toolkits?