none
Issues with app.config file RRS feed

  • Question

  • Using VS2012 I created a WCF service project which retrieves data from a database which in turn transforms the data to a JSON string which when I do invoke on the function the length property of this string the size is 166910.

    When executing the method within the service I get the following exception (which I see there is a fair amount of postings on Google).

    The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

    So in the app.config file for the service I set MaxReceivedMessageSize to 2147483647, run the service (using WCF Test Client) and get the same exception. I noticed in WCF Test Client that on the tree node if I edit the config file and set MaxReceivedMessageSize to 2147483647 then run the function again it works.

    After I close the WCF Test Client that config file I just edited is removed from disk.

    So I am wondering how to have the service recognize my app config file ?

    Thanks for any insights.

    Below is the app.config file

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's 
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="Binding1" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
              maxReceivedMessageSize="2147483647" transferMode="Streamed"
              useDefaultWebProxy="true">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <services>
          <service name="EventRegistrationLib.EventRegistrationService">
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8733/Design_Time_Addresses/EventRegistrationLib/EventRegistrationService/"   />
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint
              address=""
              binding="basicHttpBinding"
              bindingConfiguration="Binding1"
              contract="EventRegistrationLib.IEventRegistration">
              <!-- 
                  Upon deployment, the following identity element should be removed or replaced to reflect the 
                  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
                  automatically.
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
            <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Wednesday, June 5, 2013 7:59 PM

Answers

  • On 6/5/2013 3:59 PM, Kevininstructor wrote:


    So I am wondering how to have the service recognize my app config file ?

    The service doesn't recognize your config file on the client-side. The app.config or Web.config is derived from the service when a reference is set to the service in the client-side project in the VS IDE.

    As an example, if you have a classlib project, you called it FunctionalTest, the app.config is going to be generated in the classlib project based on the default settings it saw on the service reference.

    Now,  you can host that testing classlib project with Resharper, go into debug mode in Resharper and using something like MS Unit Test framework, NUnit or MBUnit, you can single-step from the client test code right into the WCF service code.

    In other words, you can go beyond in a testing scenario what the WCFTestClient can provide to you when testing the WCF services,  and you have to debug it. In a situation where you have the BLL and DAL sitting behind the WCF service, you can debug step right into the BLL and DAL code from the client, through the service, to the BLL and BLL to the DAL. This is something you cannot do with the WCFTestClient.
     Anyway, you can read the information in the link below about the WCFTestClient.
     http://msdn.microsoft.com/en-us/library/bb552364.aspx

    <copied>
     Persist Client Configuration
     The Tools->Options->Client Configuration tab contains an Always Regenerate Config When Launching Services option, which is enabled by default. This option specifies that every time WCF Test Client loads a service, it regenerates a configuration file based on the latest service contract and service App.config files.

    If you have edited the client configuration for your WCF service and want to always use this updated file to debug your service, you can uncheck the Regenerate option. By doing so, even when you update the service and reopen WCF Test Client, the Client.dll.config file is the one you updated previously instead of a regenerated one based on the updated service.

    However, you might need to edit the configuration file to make it consistent with the regenerated proxy. If the regenerated proxy and configuration file are mismatched due to an updated service, errors will occur when the service is invoked.

    <end>

    Wednesday, June 5, 2013 8:46 PM

All replies

  • On 6/5/2013 3:59 PM, Kevininstructor wrote:


    So I am wondering how to have the service recognize my app config file ?

    The service doesn't recognize your config file on the client-side. The app.config or Web.config is derived from the service when a reference is set to the service in the client-side project in the VS IDE.

    As an example, if you have a classlib project, you called it FunctionalTest, the app.config is going to be generated in the classlib project based on the default settings it saw on the service reference.

    Now,  you can host that testing classlib project with Resharper, go into debug mode in Resharper and using something like MS Unit Test framework, NUnit or MBUnit, you can single-step from the client test code right into the WCF service code.

    In other words, you can go beyond in a testing scenario what the WCFTestClient can provide to you when testing the WCF services,  and you have to debug it. In a situation where you have the BLL and DAL sitting behind the WCF service, you can debug step right into the BLL and DAL code from the client, through the service, to the BLL and BLL to the DAL. This is something you cannot do with the WCFTestClient.
     Anyway, you can read the information in the link below about the WCFTestClient.
     http://msdn.microsoft.com/en-us/library/bb552364.aspx

    <copied>
     Persist Client Configuration
     The Tools->Options->Client Configuration tab contains an Always Regenerate Config When Launching Services option, which is enabled by default. This option specifies that every time WCF Test Client loads a service, it regenerates a configuration file based on the latest service contract and service App.config files.

    If you have edited the client configuration for your WCF service and want to always use this updated file to debug your service, you can uncheck the Regenerate option. By doing so, even when you update the service and reopen WCF Test Client, the Client.dll.config file is the one you updated previously instead of a regenerated one based on the updated service.

    However, you might need to edit the configuration file to make it consistent with the regenerated proxy. If the regenerated proxy and configuration file are mismatched due to an updated service, errors will occur when the service is invoked.

    <end>

    Wednesday, June 5, 2013 8:46 PM
  • Hello darnold924,

    Yeah know the "Always regenerate config when launching services" was taunting me and I did not see it. Thanks for your assistance.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Wednesday, June 5, 2013 9:28 PM