Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service app.config

Tags:

c#

wcf

app-config

I'm developing a WCF Service and I'm a little confused about where its consuming its configurations.

I have an app.config file in my host application (console application) and in my WCF Service project (came with the template)

In run time I can see that configurations from both files are used.

How does it work? Why does the WCF library project (a dll project) contains an app.config file and what is it's purpose?

I can really use some clarifications about this ...

Update

this is the WCF configuration from my app.config in the host application

<system.serviceModel>

    <!-- services -->
    <services>
        <service name="Services.CalcService">
            <endpoint address="net.tcp://localhost:8412/MyCalcService"
                      binding="netTcpBinding"
                      bindingConfiguration="MyNetTcpBinding"
                      contract="Contracts.ICalc"/>
        </service>
    </services>

    <!-- bindings -->
    <bindings>
        <netTcpBinding>
            <binding name="MyNetTcpBinding"
                     closeTimeout="00:01:00"
                     openTimeout="00:01:00"
                     receiveTimeout="00:10:00"
                     sendTimeout="00:01:00"
                     transactionFlow="false"
                     transferMode="Streamed"
                     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" />
                </security>
            </binding>
        </netTcpBinding>
    </bindings>

</system.serviceModel>

This is my WCF configuration from my WCF service library

  <system.serviceModel>
<services>
  <service name="Services.CalcService">
    <endpoint address="" binding="basicHttpBinding" contract="Contracts.ICalc">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/Services/CalcService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>

Thanks, Omri.

like image 653
Omri Btian Avatar asked Aug 15 '13 12:08

Omri Btian


People also ask

What is binding configuration in WCF?

WCF binding propertiesSpecifies the maximum memory that can be used for an individual WCF message. Specifies the client connection mode of the transport channel. 0 means that the client connection mode is as specified in the URI. Only used if the client connection is used.

How do I find app config in Visual Studio?

In Solution Explorer, right-click the project node, and then select Add > New Item. The Add New Item dialog box appears. Expand Installed > Visual C# Items. In the middle pane, select the Application Configuration File template.

What is serviceModel in web config?

servicemodel element, there are behaviors, bindings and services. We can define various behaviors like endpoint behaviors and servicebehaviors under the behaviors element. In the binding section different bindings like basicHttpBinding, wsHttpBinding etc. In our example we define basicHttpBinding.

Where is WCF config file?

By default, WCF configuration is stored in your app. config (or web. config) file in the <system. serviceModel> section.


1 Answers

How does it work?

Only the configuration file of the host application is used.

Why does the WCF library project (a dll project) contains an app.config file

If it is in a class library I guess it's the VS template that added it.

what is it's purpose?

It could be used by the WCF Service Host (WcfSvcHost.exe) when you run the WCF service library with F5 in Visual Studio.

like image 69
Darin Dimitrov Avatar answered Oct 17 '22 03:10

Darin Dimitrov