windows 8 个单元测试项目的 WCF 服务超时
WCF Service times out from windows 8 unit test project
当应用程序 运行 时,WCF 服务按预期工作。
当从单元测试项目调用完全相同的代码时,会出现以下错误。 windows 8 个测试项目访问 WCF 服务是否有特殊需要?
Result Message: Test method
DataServiceTests.MyTest
threw exception:
System.AggregateException: One or more errors occurred. --->
System.ServiceModel.EndpointNotFoundException: Could not connect to
net.tcp://localhost:56478/MyService/DataAccessService. The connection
attempt lasted for a time span of 00:00:42.0131535. TCP error code
10060: A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond
127.0.0.1:56478. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed
because connected host has failed to respond 127.0.0.1:56478
集成测试代码:
DataAccess service = new DataAccess(
new Uri(@"net.tcp://127.0.0.1:56478/MyServices/DataAccessService"));
var bob = service.GetData();
因为您没有分享任何相关来源,所以很难完全诊断您的问题。然而...
您确定您的 WCF 服务实例已启动,运行 并且在您的测试开始之前可以访问 运行?
错误消息很好地描述了正在发生的事情:
Could not connect to net.tcp://localhost:8111/MyService/DataAccessService
The connection attempt lasted for a time span of 00:00:42.0131535.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 127.0.0.1:8111
因为这是一个商店应用程序,它在沙箱 (AppContainer) 中运行,因此某些东西(如 WCF)无法从 "unit tests" 开箱即用。为了让它工作,我必须为我的单元测试项目的开发机器添加一个环回豁免。
步骤 1
在调用 WCF 服务的单元测试项目中打开 Package.appxmanifest 文件,然后导航到 打包选项卡 。从那里,记下 包系列名称。
步骤 2 打开 Visual Studio 命令 Prompt/Developer 提示符,以管理员身份,将其粘贴到 CheckNetIsolation LoopbackExempt -a -n=UnitTestProjectPackageFamilyName
,将最后一位替换为实际的包系列名称。
当应用程序 运行 时,WCF 服务按预期工作。
当从单元测试项目调用完全相同的代码时,会出现以下错误。 windows 8 个测试项目访问 WCF 服务是否有特殊需要?
Result Message: Test method DataServiceTests.MyTest threw exception:
System.AggregateException: One or more errors occurred. ---> System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://localhost:56478/MyService/DataAccessService. The connection attempt lasted for a time span of 00:00:42.0131535. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 127.0.0.1:56478. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 127.0.0.1:56478
集成测试代码:
DataAccess service = new DataAccess(
new Uri(@"net.tcp://127.0.0.1:56478/MyServices/DataAccessService"));
var bob = service.GetData();
因为您没有分享任何相关来源,所以很难完全诊断您的问题。然而...
您确定您的 WCF 服务实例已启动,运行 并且在您的测试开始之前可以访问 运行?
错误消息很好地描述了正在发生的事情:
Could not connect to net.tcp://localhost:8111/MyService/DataAccessService
The connection attempt lasted for a time span of 00:00:42.0131535.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 127.0.0.1:8111
因为这是一个商店应用程序,它在沙箱 (AppContainer) 中运行,因此某些东西(如 WCF)无法从 "unit tests" 开箱即用。为了让它工作,我必须为我的单元测试项目的开发机器添加一个环回豁免。
步骤 1 在调用 WCF 服务的单元测试项目中打开 Package.appxmanifest 文件,然后导航到 打包选项卡 。从那里,记下 包系列名称。
步骤 2 打开 Visual Studio 命令 Prompt/Developer 提示符,以管理员身份,将其粘贴到 CheckNetIsolation LoopbackExempt -a -n=UnitTestProjectPackageFamilyName
,将最后一位替换为实际的包系列名称。