WCF VSTO 客户端部署在 win2k8 上时找不到默认端点

发布于 2024-11-09 02:21:49 字数 2958 浏览 4 评论 0 原文

我在 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 来“修复”了此问题。

I created and deployed a WCF client (launched from a VSTO Word Addin) on a Win2008R2 Terminal Server.
When excution the default constructor of the WCF proxy an InvalidOperationException is thrown, stating that the default endpoint for the contract cannot be found.

The same WCF client when deployed to a Win7 x64 machine just runs fine using the same .dll.config

I tried to create an instance inside PowerShell and receive the same error.

If creating a dedicate endpoint in PowerShell I can excute a service method:

$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 (part)

<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 (part)

<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

I "fixed" this by copying my Client.config to the Office Program Folder and renaming it to WINWORD.EXE.config.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一身软味 2024-11-16 02:21:49

此问题是由于部署项目在注册表中没有正确的清单文件条目引起的。上述解决方法之所以有效,是因为 - 没有找到加载项 word/excel 等的配置文件。在默认位置(其程序目录)中查找并查找默认配置文件名 - 在 MsWord WINWORD.EXE 的情况下。配置。

清单条目的不正确形式是:

[TARGETDIR]Addin.vsto|vstolocal

它应该是:

file:///[TARGETDIR]Addin.vsto|vstolocal

那么您的配置文件将被正确加载。

有关详细信息,请参阅 这里

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:

[TARGETDIR]Addin.vsto|vstolocal

It should be:

file:///[TARGETDIR]Addin.vsto|vstolocal

Then your config file will be loaded in correctly.

For more information see here

温馨耳语 2024-11-16 02:21:49

您可以以编程方式创建端点吗?

MyProxy proxy = new MyProxy (new BasicHttpBinding(), new EndpointAddress("http://server/Service.svc"));

如果这有效,那么很可能是配置问题。

Can you create an endpoint programmatically?

MyProxy proxy = new MyProxy (new BasicHttpBinding(), new EndpointAddress("http://server/Service.svc"));

If this works, then very probably it is a configuration issue.

疧_╮線 2024-11-16 02:21:49

我们通过 Visual Studio 2010 .NET4 创建的 Excel 2010 Addin 也遇到了完全相同的问题。我们按照本文中的更新修复解决了问题,但想详细说明修复的详细信息,请参见下文。

更新
我通过将 Client.config 复制到 Office 程序文件夹并将其重命名为 WINWORD.EXE.config 来“修复”了此问题。

我们修复的详细信息如下:

  1. 卸载我们的 Excel 2010 Addin;然后通过 Windows Installer 重新安装了我们的 Excel 2010 插件。
  2. 打开$EXCEL_HOME目录。 $EXCEL_HOME 目录是 Excel 2010 Office 程序“Excel.exe”所在的目录(对于 Windows 7 和 XP 上的我们 - C:\Program Files\Microsoft Office\Office14< /em>)
  3. 从我们的应用程序/插件配置“MyAddinProjName”.dll.config(在 Excel Addin 安装期间安装)复制已安装插件位置(C:\Program Files\Microsoft\"MyAddinProjName")到 $EXCEL_HOME 目录,
  4. 然后我们将其重命名为 “MyAddinProjName”.dll.config改为“Excel.exe.config
  5. 错误不再出现后欣喜若狂。

我们从来没有弄清楚为什么这种情况发生在某些机器上而不是其他机器上,但我们确实知道这个修复/解决方法允许我们继续测试插件功能。我们处理出现此问题的任何插件安装的解决方案是提供系统管理员可以运行的 .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.

UPDATE
I "fixed" this by copying my Client.config to the Office Program Folder and renaming it to WINWORD.EXE.config.

The details of our fix are the following:

  1. Uninstalled our Excel 2010 Addin; then Reinstalled our Excel 2010 Addin via Windows Installer.
  2. Opened the $EXCEL_HOME directory. The $EXCEL_HOME directory is the directory where the Excel 2010 Office Program "Excel.exe" is located (For us on Windows 7 and XP - C:\Program Files\Microsoft Office\Office14)
  3. Copied our application/addin config "MyAddinProjName".dll.config (which was installed during the Excel Addin installation) from our installed Addin location (C:\Program Files\Microsoft\"MyAddinProjName") to the $EXCEL_HOME directory
  4. We then renamed "MyAddinProjName".dll.config it to "Excel.exe.config"
  5. Jumped for joy after the error no longer appeared.

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文