简体   繁体   English

WCF服务app.config

[英]WCF Service app.config

I'm developing a WCF Service and I'm a little confused about where its consuming its configurations. 我正在开发一个WCF服务,我对它的配置消耗有点困惑。

I have an app.config file in my host application (console application) and in my WCF Service project (came with the template) 我的主机应用程序(控制台应用程序)和我的WCF服务项目(随模板附带)中有app.config文件

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? 为什么WCF库项目(一个DLL项目)包含一个app.config文件,它的目的是什么?

I can really use some clarifications about this ... 我真的可以对此进行一些澄清......

Update 更新

this is the WCF configuration from my app.config in the host application 这是来自主机应用程序中app.config的WCF配置

<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 这是我的WCF服务库中的WCF配置

  <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. 谢谢,Omri。

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 为什么WCF库项目(一个DLL项目)包含一个app.config文件

If it is in a class library I guess it's the VS template that added it. 如果它在类库中,我猜它是添加它的VS模板。

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. 当您在Visual Studio中使用F5运行WCF服务库时, WCF Service Host (WcfSvcHost.exe)可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM