5

I am using the new SimpleMembership framework in .Net.

The unit tests to create users (using the API - see below) work fine locally in Visual Studio 2012 IDE.

WebSecurity.CreateUserAndAccount(entity.UserName, entity.Password, new { });

However, when running on the build server (using TeamCity) I get the following below.

I have tried Dependency Walker with no luck. I also can't think how this could be run in x64 - considering VS2012 runs in x86.

Any help would be appreciated.

threw exception:

System.IO.FileNotFoundException: Could not load file or assembly 'WebMatrix.WebData' or one of its dependencies. The system cannot find the file specified.=== Pre-bind state information ===
LOG: User =  
LOG: DisplayName = WebMatrix.WebData
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: WebMatrix.WebData | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).*
Darren Oster
  • 9,146
  • 10
  • 48
  • 66
user1697278
  • 61
  • 1
  • 1
  • 3

3 Answers3

16

I ran into this as well, and it had nothing to do with MS Test or any unit testing framework, I was actually running into this in a web project, where code would compile fine but break when web.config referenced SimpleMembershipProvider. I had used the updated NuGet package Microsoft.AspNet.WebPages.WebData, which put WebMatrix.WebData in as a reference, but it failed to set CopyLocal=true.

The solution seems to be to simply set CopyLocal=true in the WebMatrix.WebData (and WebMatrix.Data) properties under the project's References.

I believe CopyLocal=false has to be explicitly set in a NuGet install script, in which case this seems to be a major design stupidity flaw, not a bug.

Jon Davis
  • 6,562
  • 5
  • 43
  • 60
  • This worked for me. Thanks a lot, wouldn't have figured it out on my own. – draconis Jan 04 '13 at 13:27
  • When I installed the NuGet package and the CopyLocal=true by default. I guess it's been updated. I am using a mstest project with EF5 code first to recreate the database if model change. My issue was resolved by add the WebMatrix.WebData.dll to this directory "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE". Thank you to all. – Diganta Kumar Mar 26 '13 at 18:44
1

This seems to be a bug in the framework. However, was fixed by placing

WebMatrix.WebData.dll

inside the MsTest directory (C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE) on the build server

user1697278
  • 61
  • 1
  • 1
  • 3
1

I fixed this error by changing the binding redirect configuration in my web config. I had set it incorrectly when upgrading a nuget package.

To fix I changed it from this:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.4.17603" newVersion="6.0.4.17603" />
      </dependentAssembly>

to this:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
B-Lat
  • 1,685
  • 1
  • 18
  • 25