WCF VSTO 客户端部署在 win2k8 上时找不到默认端点
我在 Win2008R2 终端服务器上创建并部署了一个 WCF 客户端(从 VSTO Word Addin 启动)。
当执行 WCF 代理的默认构造函数时,会抛出 InvalidOperationException
,表明找不到协定的默认端点。
当部署到 Win7 x64 计算机时,相同的 WCF 客户端可以使用相同的 .dll.config 正常运行
我尝试在 PowerShell 内创建一个实例并收到相同的错误。
如果在 PowerShell 中创建专用端点,我可以执行服务方法:
$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()
Service 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 来“修复”了此问题。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此问题是由于部署项目在注册表中没有正确的清单文件条目引起的。上述解决方法之所以有效,是因为 - 没有找到加载项 word/excel 等的配置文件。在默认位置(其程序目录)中查找并查找默认配置文件名 - 在 MsWord WINWORD.EXE 的情况下。配置。
清单条目的不正确形式是:
它应该是:
那么您的配置文件将被正确加载。
有关详细信息,请参阅 这里
This issue is caused by the deployment project not having the correct entry in the registry for the manifest file. The workarounds above work because - having not found a config file for the add-in word/excel etc. look in the default location (their program directory) and look for the default config file name - in the case of MsWord WINWORD.EXE.config.
The incorrect form for the manifest entry is:
It should be:
Then your config file will be loaded in correctly.
For more information see here
您可以以编程方式创建端点吗?
如果这有效,那么很可能是配置问题。
Can you create an endpoint programmatically?
If this works, then very probably it is a configuration issue.
我们通过 Visual Studio 2010 .NET4 创建的 Excel 2010 Addin 也遇到了完全相同的问题。我们按照本文中的更新修复解决了问题,但想详细说明修复的详细信息,请参见下文。
我们修复的详细信息如下:
我们从来没有弄清楚为什么这种情况发生在某些机器上而不是其他机器上,但我们确实知道这个修复/解决方法允许我们继续测试插件功能。我们处理出现此问题的任何插件安装的解决方案是提供系统管理员可以运行的 .bat 或 VB 脚本,该脚本会将配置文件复制并重命名到适当的位置。
我希望这些信息可以帮助每个人解决同样的问题,并澄清任何缺失的细节:)
We had the exact same problem with an Excel 2010 Addin we created via Visual Studio 2010 .NET4 . We fixed our issue by following the updated fix in this post, but wanted to elaborate with the details of our fix, see below.
The details of our fix are the following:
We never figured out why this happened on some machines and not others but we do know that this fix/work around allowed us to continue testing the Addin functionality. Our solution to handle any installations of the Addin that present this problem is to provide a .bat or VB script that the System Admins can run which will copy and rename the config file to the appropriate locations.
I hope this information helps everyone with the same problem and clarifies any missing details :)