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.
4 Answers
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>

- 72,740
- 7
- 86
- 98

- 13,909
- 3
- 34
- 50
-
Thanks for reply : My this problem is solved but i am getting same error with another assembly Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0 – Jagmohan Kasana Apr 20 '14 at 12:05
-
Repeat the previous steps with the package "Microsoft.AspNet.Razor" - see http://www.nuget.org/packages/Microsoft.AspNet.Razor/ – pwdst Apr 20 '14 at 12:12
-
If you want to install the package version 3.0.0 and not the current 3.1.0 then type "Install-Package Microsoft.AspNet.Razor -Version 3.0.0" in the Package Manage Console. – pwdst Apr 20 '14 at 12:14
-
i am still getting error : Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. when i am Installing this by Install-Package Microsoft.AspNet.Razor then i am getting response HRSystem already has a reference to 'Microsoft.AspNet.Razor 3.1.2' – Jagmohan Kasana Apr 20 '14 at 17:57
-
Thx bro this works for me Install-Package Microsoft.AspNet.WebPages.Data – Ali Apr 30 '14 at 06:10
-
Yes, upgraded package Microsoft.aspnet.webpages.data worked – Zonus Dec 30 '15 at 17:09
I had a similar problem, and I fixed it by doing the following:
Installing the package via package manager console(from visual studio) Use the following commands:
PM> Install-package WebMatrix.Data
PM> Install-package WebMatrix.WebData
Add a binding Redirect in Web.config file Between <runtime></runtime> tags:
<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>
3.I've copied both dlls from: /YourProject/packages folder to /YourProject/bin folder
(Optional) If you can't find the dlls in /YourProject/packages folder, try search for the dlls in /YourProject/bin/Debug folder, and copy/Paste them into /YourProject/bin folder instead.
It solved the problem for me.

- 177
- 1
- 6
The only thing that worked for me was editing the properties of the DLL (right-click the WebMatrix.WebData DLL in solution explorer and select Properties), changing the "Copy Local" property to true. Same for the WebMatrix.Data DLL.

- 831
- 1
- 11
- 18
Following solution helped us
step 1: Delete the service reference and build the app (will show error) step 2: Add service reference again -> click on advance button step 3: uncheck "Reuse types in referenced assemblies" and then click on OK step 4: Rebuild the application

- 1