2012-02-03 93 views
0

我有一个类库,应该建立一个连接到现有的命名管道服务器。我得到的错误是:命名管道客户端将无法启动

Could not find endpoint element with name 'internal' and contract 'SelectedStudentReference.ISelectedStudent' 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.

这里是dll.config XML:

<system.serviceModel> 
    <bindings>    
     <netNamedPipeBinding> 
      <binding name="internal" closeTimeout="00:01:00" openTimeout="00:01:00" 
       receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" 
       transferMode="Buffered" transactionProtocol="OleTransactions" 
       hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" 
       maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="Transport"> 
        <transport protectionLevel="EncryptAndSign" /> 
       </security> 
      </binding> 
     </netNamedPipeBinding> 
    </bindings> 
    <client> 
     <endpoint address="net.pipe://localhost/SelectedStudent" binding="netNamedPipeBinding" 
      bindingConfiguration="internal" contract="SelectedStudentReference.ISelectedStudent" 
      name="internal"> 
      <identity> 
       <userPrincipalName value="[email protected]" /> 
      </identity> 
     </endpoint>    
    </client> 
</system.serviceModel> 

这里是我用来实例化客户端的代码,也是在它抛出的错误:

using AwardManager.SelectedStudentReference; 

if (_client == null) _client = new SelectedStudentClient("internal"); 

我知道服务器正在运行,错误信息只提到客户端故障。从类库中执行此操作有什么问题吗?安装程序没有将.config与dll复制,我手动执行了这个,所以我不确定.dll是否注意.config。

这是一个已注册的COM可见的DLL,它是由另一个进程实例化和调用的。我无法将此system.serviceModel添加到该另一个进程的.config文件中。

我可以在代码中构建客户端,如果这样做会有效,并且我有一些如何实现该功能的示例。

我也可以对userPrincipleName使用一些帮助。它使用我的凭据似乎不正确。它不应该指定用户的凭证或一些通用凭证吗?它甚至需要包含在客户端配置中吗?

谢谢

回答

0

这东西需要在为你的DLL的EXE配置。一个DLL没有独立的配置 - 或者至少.NET不会读取它,除非你做了一些自定义的东西。

如果您不能修改宿主EXEs配置,您可能需要在代码中构建此配置。

相关问题