1

Sorry for the long title.

I am writing a Unit Test framework for Dynamics AX in C# to test an integration project we are working on using the Dynamics Connector.

The basic structure of our timesheet tests is:

  1. Create snapshot of database (AX doesn't allow mock objects)
  2. Log onto an AX instance, create Basic Data such as customer, project etc... Logoff
  3. Create the timesheet item for the test
  4. Post the timesheet using a call to the document service
  5. Retrieve the timesheet
  6. Assert

On some tests we are experiencing an error message on point 5 which is saying

System.ServiceModel.CommunicationException: 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. ---> System.ServiceModel.QuotaExceededException: 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.

I have split the message up into two as it sounds like two different errors

TestCleanup method ... threw exception. System.ServiceModel.CommunicationObjectFaultedException: System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state

With us using the AIF I can't do the top part because the binding xml is nowhere to be seen (as far as we know)

The strange thing is, this error doesnt seem to come consitently but we are cleaining up everything that we can see on the test.

Can anyone help me? Even if it is just suggesting things to try.

Another thing to note is that these errors quite often cause the dynamics ax service to crash which makes debugging it a complete pain in the backside

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Keithin8a
  • 961
  • 7
  • 32

1 Answers1

3

Change the configuration of the AIF port. You have to change the maxReceivedMessageSize for the binding.

Example:

<configuration>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="DefaultServiceGroupBinding" 
            maxReceivedMessageSize="104857600" 
            ...
        />
      </netTcpBinding>
    </bindings>
    ...
<configuration>

AIF WCF Binding Configuration

Matej
  • 7,517
  • 2
  • 36
  • 45
  • Unfortunately that didnt work. When I went into the service the MaxReceivedMessageSize was already set to that number. I did try to double it though but I still get the same error. Out of curiosity how did you access the XML? – Keithin8a Oct 30 '14 at 10:40
  • 1
    It seems that your test client has also that limitation. Change the WCF configuration binding in the C# project `app.config` file (you can also right click *app.config* within the Visual Studio and select *Edit WCF configuration*). This file is temporary stored - use *Save as...* to inspect temporary file. – Matej Oct 30 '14 at 11:05
  • Thanks for all your help. A couple of bonus questions for you :) The service still seems to be crashing after every test run is this a related symptom? Also I spoke to someone and they said the app.config files were auto generated, do you know why they would auto generate incorrectly? Thanks for you help – Keithin8a Oct 30 '14 at 11:39
  • Apparently the auto generation is a bug that we have already noticed before and have logged with Microsoft so hopefully that will be fixed in the next release. I still don't know why it is turning off the service, i suspect it will be unrelated. – Keithin8a Oct 30 '14 at 11:50
  • The "crashing" may be related to the client connection not being closed after it is used. In the C# app, use a using statement or client.close() after you are done with the call. – RT. Oct 30 '14 at 16:16