我編寫了一個在DLL中引用的WCF服務。 在我添加了服務引用後,一個app.config自動生成了需要的數據。引用的WCF服務不使用app.config
客戶端正在使用dll與wcf服務進行通信......沒有什麼特別的。 但是,當我試圖創建一個服務引用的對象,它崩潰,說它無法找到一個端點地址。
我用Google搜索周圍,通過passsing的綁定和地址,該服務的參考固定它:
readonly BasicHttpBinding _binding = new BasicHttpBinding();
readonly EndpointAddress _address = new EndpointAddress("http://localhost:50309/CustomerService.svc");
using (CustomerServiceClient client = new CustomerServiceClient(_binding, _address))
{
return client.GetActions(customerNumber);
}
現在我想知道,爲什麼我要傳遞的參數,當這些數據已經在自動生成app.config。 我刪除了app.config的內容......並且似乎這些數據不會在任何地方使用。
我做錯了什麼?
編輯:在dll項目
應用程序配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICustomerService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:50309/CustomerService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICustomerService"
contract="ServiceReference.ICustomerService" name="BasicHttpBinding_ICustomerService" />
</client>
</system.serviceModel>
</configuration>
請包括你的app.config。另外我假設app.config是爲你的入口點.exe – Aron 2013-03-28 09:13:12
你確定你的DLL不使用你的客戶端的app.config?或者你在談論那個DLL的app.config? – 2013-03-28 09:13:15
如果你的dll看起來像app.config,你最有可能使用錯誤的。 – 2013-03-28 09:21:44