命名管道客户端无法启动

发布于 2025-01-02 12:32:15 字数 2324 浏览 1 评论 0原文

我有一个类库,应该建立与现有命名管道服务器的连接。我得到的错误是:

在 ServiceModel 客户端配置部分中找不到名称为“internal”且合同为“SelectedStudentReference.ISelectedStudent”的端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

这是 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 的一些帮助。它使用我的凭据似乎不正确。它不应该指定用户的凭据或一些通用凭据吗?它是否需要包含在客户端配置中?

谢谢

I have a class library that is supposed to build a connection to an existing named-pipes server. The error I get is:

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.

Here is xml from dll.config:

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

Here is the code I use to instanciate the client, and also where it throws the error:

using AwardManager.SelectedStudentReference;

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

I know the server is running and the error message only mentions the client failure. Is there any problem doing this from a class library? The install program did not copy the .config out with the dll, I did that manually, so I'm not sure the .dll is paying attention to the .config.

This is a registered COM-visible dll that is instanciated and called by another process. I'm not able to add this system.serviceModel to the .config for that other process.

I could build the client in code, if that would work and I had some examples of how to accomplish that.

I could also use some help with the userPrincipleName. It doesn't seem correct for it to use my credentials. Shouldn't it specify the user's credentials, or some generic credentials? Does it even need to be included in the client configuration?

Thanks

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

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

发布评论

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

评论(1

热血少△年 2025-01-09 12:32:15

这些内容需要位于托管 DLL 的 exe 的配置中。 DLL 没有独立的配置 - 或者至少 .NET 不会读取它,除非您执行一些自定义操作。

如果您无法修改托管 EXE 配置,您可能必须在代码中构建此配置。

This stuff needs to be in the config for the exe that hosts your DLL. A DLL does not have a stand-alone config - or at least .NET does not read it unless you do something custom.

If you can't modify the hosting EXEs config, you're probably going to have to build this configuration in code.

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