我在Win2008R2終端服務器上創建並部署了WCF客戶端(從VSTO Word Addin啓動)。 當執行WCF代理的默認構造函數時,會拋出InvalidOperationException
,指出找不到合同的默認端點。WCF VSTO客戶端在win2k8上部署時找不到默認端點
在部署到Win7的X64機剛運行正常使用相同的.dll.config
我試圖創建內部PowerShell的一個實例,並收到同樣的錯誤相同的WCF客戶端。
如果在PowerShell中創建奉獻端點我可以EXCUTE服務的方法:
$binding = New-Object System.ServiceModel.BasicHttpBinding
$endpoint = New-Object System.ServiceModel.EndPointAddress("http://myserver:7777/CompanyService.svc")
$client = New-Object MyClient.CompanyServiceReference.CompanyServiceClient($binding, $endpoint)
$v = $client.Version()
服務Web.Config(部分)
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="NoHttpSecurity" sendTimeout="00:03:00">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="CompanyService">
<endpoint address="http://myserver:7777/mex" contract="IMetadataExchange" binding="mexHttpBinding" />
<endpoint name="Version" address="http://myserver:7777/Version" contract="MyService.ICompanyService" binding="basicHttpBinding" bindingConfiguration="NoHttpSecurity" />
<endpoint name="CompanyList" address="http://myserver:7777/CompanyList" contract="MyService.ICompanyService" binding="basicHttpBinding" bindingConfiguration="NoHttpSecurity" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
MyClient.dll.config(部分)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICompanyService" closeTimeout="00:01:00">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myserver:7777/CompanyService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICompanyService"
contract="CompanyServiceReference.ICompanyService" name="BasicHttpBinding_ICompanyService" />
</client>
</system.serviceModel>
UPDATE
我複製我的Client.config到Office程序文件夾,並將其重命名爲WINWORD.EXE.config 「固定」 這一點。
可能http://stackoverflow.com/questions/2192970/wcfexception-could-not-find-default-endpoint-element-that-references-contract-i – 2011-05-24 13:27:56
的副本@Roy:因爲我可以確認工作配置已經到位,所以不是重複的。 – Filburt 2011-05-24 13:32:44
你有沒有解決這個問題?我們有完全相同的問題 - 從excel插件中灌輸wcf代理客戶端,並且在某些機器win7 64和xp 32上部署但在其他win7 64和xp 32上無法正常工作!看起來好像它沒有采用配置,因爲即使我把它擰在不工作的機器上,它似乎不在乎 - 就好像它沒有那麼遠。謝謝 – 2011-07-01 12:49:24