5

SimpleMembership在.Net 中使用新框架。

创建用户的单元测试(使用 API - 见下文)在 Visual Studio 2012 IDE 中本地运行良好。

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

但是,在构建服务器上运行时(使用 TeamCity),我得到以下信息。

我尝试过 Dependency Walker,但没有成功。我也想不出这怎么能在 x64 中运行——考虑到 VS2012 在 x86 中运行。

任何帮助,将不胜感激。

抛出异常:

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).*
4

3 回答 3

17

我也遇到了这个问题,它与 MS Test 或任何单元测试框架无关,我实际上是在一个 Web 项目中遇到这个问题,其中代码可以很好地编译,但是当 web.config 引用 SimpleMembershipProvider 时会中断。我使用了更新的 NuGet 包 Microsoft.AspNet.WebPages.WebData,它把 WebMatrix.WebData 作为参考,但它未能设置 CopyLocal=true。

解决方案似乎是在项目的引用下的 WebMatrix.WebData(和 WebMatrix.Data)属性中简单地设置 CopyLocal=true。

我相信 CopyLocal=false 必须在 NuGet 安装脚本中明确设置,在这种情况下,这似乎是一个主要的设计愚蠢缺陷,而不是错误。

于 2012-11-27T17:23:07.260 回答
1

这似乎是框架中的一个错误。但是,通过放置固定

WebMatrix.WebData.dll

在构建服务器上的 MsTest 目录 (C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE) 内

于 2012-11-08T11:21:54.173 回答
0

我通过更改 Web 配置中的绑定重定向配置来修复此错误。我在升级 nuget 包时设置错误。

为了解决这个问题,我改变了它:

<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>

对此:

<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>
于 2014-10-27T11:49:19.443 回答