Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleMembership MVC3 Could not load file or assembly WebMatrix.Data

I'm using the SimpleMembership.MVC3 package to manage membership. Everything works fine at development but when I deploy to my Azure web role, It throws the following exception:

Could not load file or assembly 'WebMatrix.Data, Version=1.0.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)

stack trace: [FileLoadException: Could not load file or assembly 'WebMatrix.Data, Version=1.0.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)]
WebMatrix.WebData.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'WebMatrix.Data, Version=1.0.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).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +11711966
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +465
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167

[HttpException (0x80004005): The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'WebMatrix.Data, Version=1.0.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).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869125

There's no WebMatrix.Data assembly downloaded when I install the Nuget Package. I've manually added the WeBMatrix.Data.DLL found at my Program Files/Microsoft ASP.NET directory, but the version of this assembly is 2.x, and the one missing is version 1.x

What is missing?

like image 272
Sebastián Odena Avatar asked Nov 30 '22 05:11

Sebastián Odena


2 Answers

I had the same issue. I right-clicked on the Reference in the Project and went to Properties. Change the CopyToLocal setting from True to False and rebuilt the project. Resolved my issue.

like image 157
Steve H. Avatar answered Dec 06 '22 12:12

Steve H.


Try adding the Reference from Nuget instead of the local reference. This solved my issue.

Here is the package: https://www.nuget.org/packages/WebMatrix.Data/

like image 25
Alberto Estrella Avatar answered Dec 06 '22 13:12

Alberto Estrella