Could not load file or assembly 'Microsoft.Build.Framework'(VS 2017)

When I try running the command "update-database", I get this exception:

Specify the '-Verbose' flag to view the SQL statements being applied to the target database. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

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

I believe I had the same issue as you did. I didn't save the whole error message, but my error message was

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

I am using Visual Studio 2017 and was trying to do Update-Database after Add-Migration.

To resolve the issue I closed Visual Studio and re-opened it, then re-ran Update-Database again.

This may or may not resolve your issue, but I thought I'd post just in case it would help.

How to resolve “Could not load file or assembly … or one of its , How to resolve “Could not load file or assembly … or one of its dependencies” and why this exception thrown in .Net? Chirag Rupani. Could not load file or assembly ‘[assemblyname]’ or one of its dependencies. An attempt was made to load a program with an incorrect format. No fear, though, as this is usually easily fixed. In quite a few cases, it’s simply a mismatch between architectures and easily changed. Reason

Our local build script was using an older version of nuget.exe (4.7.1.5393) to restore NuGet packages. We started getting this error after updating to Visual Studio 2019 version 16.5.0. Updating to the latest version of nuget.exe (5.4.0.6315) fixed the issue for us.

nuget.exe can be downloaded here: https://www.nuget.org/downloads.

Could not load file or assembly or one of its dependencies, Check if you are referencing an assembly which in turn referencing an old version of unity. For example let's say you have an assembly called� Additional information: Could not load file or assembly 'Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The root cause of this problem comes from relative paths in the devenv.exe.config file to Microsoft.Build.Framework.dll (see xml tags).

Some Visual Studio Extensions are changing the current directory and makes relative paths invalid.

To fix it, open this file in the C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ directory. and replace all ..\..\MSBuild\15.0\Bin\ by C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\.

Error : Could not load file or assembly or one of it's dependencies , Yeah!!! I found a solution for this terrible error First of all Thanks for every one who tried to help me Here's my solution Right Click on the� In the new window choose Assemblies and fill in "System.configuration" in the search box. Is the checkbox checked? If not, hover over it, select it..NET version 4.6.1 It could be that you forgot to add the nugget package?

I've found a workaround that seems to resolve the issue for good, at least on my environment running VS 2017 Professional 15.5.2 and Entity Framework 6.1.1.

Basically, install the DLL (with a few related ones) into the GAC (Global Assembly Cache) and the issue will go away.

Follow these steps:

  1. Close all running instances of Visual Studio 2017

  2. Launch the Visual Studio 2017 Developer Command Prompt

  3. Type the following commands (replace Professional with your edition, either Enterprise or Community, or adjust the path accordingly):

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Engine.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Conversion.Core.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll"

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Utilities.Core.dll"
  1. Restart Visual Studio 2017

In essence, the GAC will (in most cases) be given priority when .NET is trying to load a DLL and the FileNotFoundException will go away as your DLL will now be resolved through the GAC.

Again, it works for me and it's simply a workaround, it won't solve the core issue itself but at least I don't have to restart VS all the time when trying to work with EF migrations, and that's good enough for me.

[Solved] Could not load file or assembly (dll file), So it works if I change in the c# project from Any CPU to x86(all dlls are compiled in WIN32) from Properties -> Build -> Platform Target. I have found plenty of information out there about this error: 'ERROR: Could not load file or assembly '*.dll' or one of its dependencies. Access is denied.’ But i haven't found answer specific to my scenario. My site is deploy on 6 different production servers, only on one server i am facing this issue.

This worked for me - appears to be a non-support issue beginning in 2020.

In the Azure Build Pipeline > NuGet tool installer step, change Version of NuGet.exe to install to a newer version, like 5.4.0. Check versions at https://dist.nuget.org/tools.json.

Issue disappeared and now builds successfully.

Could not load file or assembly 'xxx' or one of its dependencies error , The system could not find the 'Episerver.Forms.Core' assembly file to load. There are some workarounds for this issue: The dll file may not be in� Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. What had happened was through nuget package manager, I had accidentally installed "Microsoft ASP.NET MVC" which installed dependencies for:

Fixing the "Could not load file or assembly or one of its , This post describes how to fix the “Could not load file or assembly '[ assemblyname]' or one of its dependencies. An attempt was made to load a� "Could not load file or assembly "Oracle.DataAccess" or one of its dependencies. An attempt was made to load a program with an incorrect format." Below are the things that I already tried. 1) replaced all the oracle dll's with 32 bit oracle dll i.e 2.112.3.0

Could not Load File or Assembly or one of its , The located assembly's manifest definition does not match the assembly reference. _. The bin folder of the Web application did have a Newtonsoft� Hi, while runing a .net setup project i got the following error: Could not load file or assembly 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Could not load file or assembly 'RFA8_NET150_x64.dll' or one of its , Could not load file or assembly 'RFA8_NET150_x64.dll' or one of its dependencies. The specified module could not be found. We get error� Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. Do I really need to install all the feature packs of SQL Server? So in this case 2017 and 2019?

Comments
  • In German, this error message reads: "Die Datei oder Assembly "Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abhängigkeit davon wurde nicht gefunden".
  • Yes, it would appear that "Turn-It-Off-And-On-Again" is the correct path to resolution in this case.
  • This works but I don't consider it as a correct answer. I would like to fix it once and forever, without having to restart VS.
  • It happens everytime after a migration now and it requires a full PC reboot to work.
  • I have tried every of the proposed solutions. None of them seems to permanently solve the problem. I have to keep restarting Visual Studio.
  • This is an open issue in Github here github.com/aspnet/EntityFramework6/issues/382
  • Faced that challenge when we installed only VS2019 on a build server. To fix this in our Azure DevOps build it works to request version 5.4.0 in the NuGet tool installer step.
  • Upgraded from 4.3.0 to 5.6 on my TeamCity. This fixed my issue. Thanks!
  • This was it. Thanks a bunch! Went from 4.4.1 to 5.4.0.
  • @ElderSmash We're using an Azure DevOps build too. In our case the problem was solved by updating the NuGet installer step from NuGetToolInstaller@0 to NuGetToolInstaller@1, even without specifying a newer version. Not sure though, whether this fixes the root cause of the problem or the fix is just a side-effect of clearing the local cache.
  • @ElderSmash That was exactly my problem and solution to, thanks!
  • I am using Visual Studio Professioal should I also do the same. I am getting this error multiple times?
  • I did not have a MSBuild folder under IDE (Community version), I copied my MSBuild from "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community" and it didn't fix anything.