Missing an assembly reference in Visual Studio

Many times when we open visual studio we face missing assembly problem. This problem mainly faced by the developer in existing which converted into the new visual studio project or take the latest version of source code from source control.

For example  - convert visual studio 2013 project to visual studio 2015 or take project source code from source control.

You will see the following screen with yellow mark on the assembly that means assembly reference is missing and visual studio not able to find .dll files.

"Package" is the folder which mainly stores all assembly which using by project and visual studio store and takes reference of the assembly from this folder.

Sometimes you will see the package folder with sub folder with assembly names but .dll files are missing inside the folder.

Have a look at the following screens. Today I am showing you how to resolve missing an assembly reference in Visual Studio.



Here are the four solutions to resolve missing an assembly reference problem in Visual Studio.

  1. Change framework version
  2. "Restore NuGet Packages" options
  3. Remove packages folder
  4. Remove packages folder
Solution -1 - Change framework version to fix Missing an assembly reference problem in Visual Studio.

Right click on the project and select properties then click on build and change framework version and then build a project.





Solution -2 - "Restore NuGet Packages" options to fix Missing an assembly reference problem in Visual Studio.

It's an easy to step to restore Nuget packages.



Solution - 3 - Remove a tag from ".csproj" file to fix Missing an assembly reference problem in Visual Studio.

Go to .csproj file edit into notepad and remove following tag and then restart the project.

  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
    <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
  </Target>

Solution - 4 - Remove packages folder to fix Missing an assembly reference problem in Visual Studio.

In this step remove packages folder and go to package manager and run following command.
After successful installation of packages close project and restart project.

Update-Package -reinstall





Previous
Next Post »
Thanks for your comment