Search code examples
wcfwcf-bindingwcf-securitywcf-client

Named-Pipes client won't start


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="name@company.org" />
            </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


Solution

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