0

I have this App.config in my wcf service library:

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="addr" value="net.tcp://localhost:22222/AdministrationService/"/>
  </appSettings>
  <system.serviceModel>
    <services>
      <service name="Watchman.WcfService.AdministrationService" behaviorConfiguration="MyBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:22222/AdministrationService/"/>
          </baseAddresses>
        </host>
        <endpoint name="Ep1" address="net.tcp://localhost/AdministrationService/" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="Watchman.WcfService.Interfaces.IAdministration"/>
        <endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="MyBehavior">
          <serviceThrottling maxConcurrentSessions="10000"/>
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/AdministrationService/Ep1/wsdl"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <netTcpBinding>
        <binding name="DuplexBinding" sendTimeout="00:00:01">
          <reliableSession enabled="true"/>
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
  </startup>

</configuration>

but I got error:

"The Address property on ChannelFactory.Endpoint was null.  The ChannelFactory's Endpoint must have a valid Address specified."

It seems like application doesn't this tcp.net endpoint. Why?

Saint
  • 5,397
  • 22
  • 63
  • 107

3 Answers3

1

I have this App.config in my wcf service library

You cannot have an app.config in a wcf class library and expect WCF to read settings from it. It doesn't make sense. Config files such as app.config are defined in the final executable application project (such as a Console application, WinForms, WPF, ...). Or if it is a web application you use a web.config. But there is not such thing as app.config for a class library. So you might need to include this WCF configuration in the app/web.config of the application using your class library.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • -1: I believe you [*can* have an app.config on a class library](http://stackoverflow.com/questions/690313/using-app-config-with-a-class-library). – Peter K. Sep 08 '11 at 19:52
  • @Peter K., and how are you gonna tell WCF to use settings that are defined in this *custom app.config* file instead of where WCF expects settings to be => which is the real app.config, the one defined for the application? – Darin Dimitrov Sep 08 '11 at 19:54
  • I put it into wcf service library and to console application that host this service - nothing has changed – Saint Sep 08 '11 at 19:54
  • @Saint, well maybe showing your code might help as well. You have posted only some `app.config` which is not clear where did you deploy, ... We don't even know (yet) how are you trying to expose/consume this service. – Darin Dimitrov Sep 08 '11 at 19:55
  • @Darin: I agree that the settings need to be in the eventual config file of the app using them. Your statement `You cannot have an app.config in a class library` is wrong, or at best misleading. – Peter K. Sep 08 '11 at 19:56
  • @Peter K., OK, I said this in the context of the question: which is WCF. But I agree with you that it could be misinterpreted. I will fix my answer. – Darin Dimitrov Sep 08 '11 at 19:57
  • I just noticed that svcutil generate bad endpoint in wcf client. There's "" instead of my net.tcp endpoint. Hmm...why? – Saint Sep 08 '11 at 20:06
0

You have specified a base address for net.tcp, so the address on the net.tcp endpoint becomes a relative address. So, effectively the address of the end point becomes net.tcp://localhost:22222/AdministrationService/localhost/AdministrationService/.

Change the address on the endpoint to a relative address and re-generate the proxy class using svcutil.

Kiran Mothe
  • 685
  • 5
  • 10
  • Kiran Mothe, I did it but nothing change. Show my comment to Darin Dimitrov and @Peter K. below. – Saint Sep 09 '11 at 16:15
0

I just noticed that svcutil generates bad endpoint in wcf client project. There's

<endpoint binding="basicHttpBinding"
          bindingConfiguration="DefaultBinding_IAdministration" 
          contract="IAdministration" 
          name="DefaultBinding_IAdministration_IAdministration" />"

instead of my net.tcp endpoint.

I also observed that's because of generation of ProxyFile.cs and App.config from

svcutil WcfServiceLibrary.dll

If I generate this files from metadata like:

svcutil net.tcp://localhost:8080/AdministrationService/mex /language:C# /out:ProxyFile.cs /config:App.config

then it works fine (in App config is described correct net.tcp endpoint)

Does anyone knows why cooperation svcutil with *.dll goes wrong?

Saint
  • 5,397
  • 22
  • 63
  • 107