找不到引用合同的默认端点元素 ServiceModel客户端中的“XXXServiceReference.XXXService” 配置部分。这可能是因为没有配置文件 找到您的应用程序,或者因为没有端点元素匹配 这个合同可以在客户元素中找到。
异常但我偶尔得到这个错误(1/3失败)这里可能出现的问题是我的配置文件
<system.serviceModel>
<client>
<endpoint address="http://address:8091/XXXService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IXXXService"
contract="XXXServiceReference.IXXXService" name="BasicHttpBinding_IXXXService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IXXXService" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
我将我的服务定义为
private XXXServiceClient sClient;
bool success = false;
int numOfEntrance = 0;
while (!success && (numOfEntrance < 20))
{
numOfEntrance++;
try
{
sClient = new XXXServiceClient();
success = true;
}
catch (Exception)
{
success = false;
Thread.Sleep(500);
if (numOfEntrance == 19)
MessageBox.Show("Connection Problem");
}
}
我试过这个,因为它时不时地进入。我想虽然可能有机会摆脱这个问题,但它没有。可能是什么问题?可能是因为服务提供商。顺便说一句,我试图从合同中删除“XXXServiceClient”部分,但它没有用。
答案 0 :(得分:0)
我怀疑这是由IIS托管服务器的不稳定性造成的,或者托管网站闲置,然后必须在下次调用时进行热备份。以下文章介绍了如何将IIS applicationHost.config
配置为自动启动:
http://weblogs.asp.net/scottgu/auto-start-asp-net-applications-vs-2010-and-net-4-0-series