让我告诉你我的项目结构,我的服务是由一个类库项目调用的,而我的客户端应用程序又调用了它,它是outlook的一个插件。我的类库和客户端项目都有相同的绑定配置。 注意 - 当我在本地运行代码时,我没有收到此错误,但是当我将其部署到其他计算机(或服务器)时,它会抛出此错误。
自从我面对这个问题差不多一周后,请帮助我。提前谢谢。错误:
无法在ServiceModel客户端配置部分中找到引用合同“CreateContactService.ICreateContactService”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。
App.Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICreateContactService" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" bypassProxyOnLocal="false"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://vmsrvweba:8080/CreateContactService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICreateContactService"
contract="CreateContactService.ICreateContactService"
name="BasicHttpBinding_ICreateContactService" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="ContactSyncEndPointBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ContactSyncBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="200" maxConcurrentSessions="200" />
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
C#代码呼叫服务方法
private static CreateContactServiceClient _GetClientService = default(CreateContactServiceClient);
_GetClientService = new CreateContactServiceClient();
List<Contact> contactsFromDb = new List<Contact>();
contactsFromDb = getClientServices.GetContacts();