"找不到名称为终结点元素..." [英] "Could not find endpoint element with name..."

查看:567
本文介绍了"找不到名称为终结点元素..."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉的长期问题的陈述......我花了两天时间调试,并有很多笔记...

Sorry for the long problem statement...I've spent two days debugging and have a lot of notes...

我有一个WCF数据服务,另一进程尝试连接到它作为通过TCP和/或HTTP客户端。

I have a WCF data service and another process trying to connect to it as a client via TCP and/or HTTP.

我有一个看起来正常连接一个非常简单的测试客户端应用程序,但更复杂生产应用程序无法连接(没有TCP或HTTP)。在这两个客户项目,我让Visual Studio 2008中生成,通过使用添加服务引用,并让它拉从数据服务元数据的app.config。

I have a VERY simple test client app that seems to connect fine, but the more complicated production app cannot connect (neither TCP or HTTP). In both client projects, I let Visual Studio 2008 generate the app.config by using "Add Service Reference" and letting it pull metadata from the data service.

下面是对于简单的测试客户端运行的代码:

Here is the code for the simple test client that works:

using Client.MyDataService;

namespace Client
{
    class Program
    {
        static void Main(string[] args)
        {
            MyDataServiceClient client = new MyDataServiceClient("net.tcp");

            client.GetRecords();
        }
    }
}



下面是代码更复杂,生产客户端:

Here is the code for the more complicated, production client:

DataServiceManager.cs:

DataServiceManager.cs:

using MyServer.MyDataService;

namespace MyServer.DataServiceBridge
{
    class DataServiceManager
    {
        MyDataServiceClient dataServiceClient = new MyDataServiceClient("net.tcp");
}
}

在主要流程:

DataServiceManager d = new DataServiceManager();

下面是两个简单的客户端和客户端的生产app.config文件:

Here is the app.config file for both simple client and production client:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="net.tcp" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
                    transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://localhost:8888/MyDataService"
                binding="netTcpBinding" bindingConfiguration="net.tcp" contract="MyDataService.IMyDataService"
                name="net.tcp">
                <identity>
                    <userPrincipalName value="COMPUTER_NAME\Username" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>




  • 在要播的bin\Debug\文件夹是
    MyServer.exe,app.config中。

    • In MyServer's bin\Debug\ folder is MyServer.exe, app.config.

      在MyDataSeriviceHost的bin\Debug\
      文件夹是MyDataService.exe,
      的app.config,和
      MyDataSeriviceHost.exe.config。
      的app.config和
      MyDataSeriviceHost.exe.config是
      相同。

      In MyDataSeriviceHost's bin\Debug\ folder is MyDataService.exe, app.config, and MyDataSeriviceHost.exe.config. app.config and MyDataSeriviceHost.exe.config are identical.

      以下是错误消息:

      An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll but 
      was not handled in user code
      
      Additional information: Could not find endpoint element with name 'net.tcp' and contract
       'MyDataService.IMyDataService' in the ServiceModel client configuration section.
       This might be because no configuration file was found for your application, or because no endpoint
       element matching this name could be found in the client element.
      



      任何想法是怎么回事?我已经差不多用尽了谷歌。 : - (

      Any ideas what is going on? I've pretty much exhausted Google. :-(

      推荐答案

      解决

      事实证明,我们有加载的DLL。
      中的DLL exe文件包含WCF客户端。
      编译时,MyServer.dll.config产生,但由于该exe是本地(不是.NET)它不读。.config文件自动文件中,我们需要做手工
      此链接让我手动加载配置文件以及创建一个CustomChannelFactory<>来解决这个问题。

      It turns out that we have an exe that loads a DLL. The DLL contains the WCF client. When compiled, MyServer.dll.config is generated, but since the exe is native (not .NET) it does not read in a .config file automatically. We need to do it manually. This link allowed me to load the config manually and create a CustomChannelFactory<> to solve this question.

      对于任何人需要同样的事情,这里是导致该解决方案的链接:
      http://www.paraesthesia.com/archive/2008/11/26/reading-wcf-configuration-from-a-custom-location.aspx

      For anybody else needing the same thing, here is the link that led to the solution: http://www.paraesthesia.com/archive/2008/11/26/reading-wcf-configuration-from-a-custom-location.aspx

      这篇关于&QUOT;找不到名称为终结点元素...&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆