Asp.net-mvc – Could not load file or assembly ‘WebMatrix.Data, Version=3.0.0.0

asp.net-mvc

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

Best Answer

Is this a solution that you have created or one you have downloaded (as a sample or as work done by a colleague)? Do you have an up to data version of NuGet installed within Visual Studio and have you checked installed packages for the project - you may need to restore packages if you have downloaded the solution from Source Control or as a zip sample online.

The easiest way to do this is to check that NuGet Package Manager is up to date in "Tools" > "Extensions and Updates" and then (with the applicable project selected in Visual Studio) select "Project" > "Manage NuGet Packages". If there are installed Packages which are not found in your solution packages directory then NuGet should offer to restore them for you.

Alternatively you may have added a package which has a dependency on that package, and you either do not have it installed or have a previous version.

To install the package within NuGet Package Manager Console type-

Install-Package Microsoft.AspNet.WebPages.Data

Or search for "Microsoft.AspNet.WebPages.Data" in the "Manage NuGet Packages" window, accessed via the instructions above.

If you have a prior version of the package installed, you may need to remap that version number to the version 3.0.0.0 with the following code in your project config (most likely Web.config) file in order to avoid breaking packages with dependencies on the previous version-

<dependentAssembly>
  <assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>