WCF调用在构建服务器上的单元测试中失败

时间:2013-01-10 19:46:12

标签: unit-testing msbuild tfs2012

我们正在运行更新的2008服务器,并在开发计算机上运行TFS 2012和VS 2012。该解决方案使用MSBuild在服务器上部署和运行测试。所有测试都在开发框上传递,但只有那些不调用本地部署的WCF服务器(在IIS中托管)的测试失败。所有服务调用的例外情况如下:

>     Test method TestProject.TestClass.TestMethod threw exception: 
>     System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel,
> cannot be used for communication because it is in the Faulted state.
>      
>     Server stack trace: 
>        at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan
> timeout)
>        at System.ServiceModel.Channels.ServiceChannel.System.IDisposable.Dispose()
>     Exception rethrown at [0
enter code here

NETWORK SERVICE具有相应的权限。电源打开了。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

解决。首先介绍设置

有问题的服务配置了利用SQL成员资格提供程序和服务证书的用户名身份验证。使用ASP.NET角色提供程序完成授权。正在使用的绑定是NetTcpBinding,其中包含消息安全性并配置为用户名。

问题结果如下:我本地邮箱上的MSBuild和MSTest在我的帐户下运行。我在本地生成的用于authorizat的证书已添加到当前用户\可信人员中,这很好;但是在构建框上,因为MSBuild和MSTest在NETWORK SERVICE下运行,WCF拒绝握手。 此问题的解决方案是将测试证书添加到“本地计算机\受信任人”存储中。