Search code examples
c#serializationdynamics-crmdynamics-crm-2015

Execute multiple requests in transaction error in crm 2015


i developed an application using the CRM 2015 SDK(v7.1.2). i want to send 2 requests for crm by ExecuteTransactionRequest, but i got an error:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter
 http://schemas.microsoft.com/xrm/2011/Contracts/Services:request. The
 InnerException message was 'Error in line 1 position 451. Element
 'http://schemas.microsoft.com/xrm/2011/Contracts/Services:request'
contains data from a type that maps to the name
 'http://schemas.microsoft.com/xrm/2011/Contracts:ExecuteTransactionRequest'.
 The deserializer has no knowledge of any type that maps to this name.
Consider changing the implementation of the ResolveName method on your
DataContractResolver to return a non-null value for name
 'ExecuteTransactionRequest' and namespace
 'http://schemas.microsoft.com/xrm/2011/Contracts'.'

this is my applicaion's picture

i used this link: https://msdn.microsoft.com/en-us/library/mt634414.aspx

please help me!!!


Solution

  • See section "Execute messages in a single database transaction" in: https://msdn.microsoft.com/en-us/library/gg328075(v=crm.7).aspx

    What you have found is that this message is in your client SDK, but that does not imply that it is also on the server. You have SDK 7.1 but on the server you have 7.0 - go to your CRm installation directory (probably C:\Program Files\Microsoft Dynamics CRM), go to Server/bin and check the version of Microsoft.Xrm.Sdk.dll. It will be something like 7.0.1 and it does not contain this message. Iagree that MS online documentation is misleading, because it shows this message for CRM 2015, but unfortunately it's not available there. As for transaction you can do this like we all did before CRM 2015 update 1 - by using CRM Command pattern. Create an entity (call it Command or whatever) and make a plugin that runs on Create (for example there can be many approaches but this is the simpliest).

    Everything that you do in plugin in Stage 20 and 40 will be run in transaction, so you can put this logic in this plugin. Of course this "Command" entity can have some parameters that you pass in, so you can different logic for different parameters that you pass to that entity. Hope that is clear for you. This is not as elegant like ExecuteTransaction but does it's job very well and it had to be done like that for many versions of CRM so I'm sure it works.