This article describes how to simulate a long operation in Dynamics 365 (CRM) using a simple custom plugin that introduces a delay using the Thread.Sleep function.
Background: recently we have been investigating an issue regarding some timeouts happening in a third party application which connects to our Dynamics 365 service. At the moment, it is difficult to tell if those timeouts are due to some slow connections to Dynamics or other reasons. In order to help us with this investigation, we are going to set the Timeout property of the OrganizationServiceProxy in the client application, which by default is 2 minutes.
Before applying this change, we also want to test it and simulate some long queries that would last longer than the client timeout limit set for the OrganizationServiceProxy. Here is where we have created this simple plugin “DelayOperation” that is going to introduce a delay for a certain number of seconds.
For testing purpose, I have prepared a simple test that creates a Task record. See below the corresponding code:
Then we have registered our “DelayOperation” plugin in the create message of the Task entity, see below this plugin registration step:
Notice we pass the number of milliseconds to be used by the Thread.Sleep function as an unsafe plugin parameter. In our example, the client would wait for 10 seconds and the plugin would delay the operation for 12 seconds, causing the client to timeout.
Finally, our “DelayOperation” plugin code is:
You can download all this code from the following Github project:
I hope you find it useful!
The new CRM SDK 2015 doesn’t give support yet for our known CRM Developer Toolkit, which has been part of the CRM SDK until CRM 2013. Basically, the CRM SDK 2015 assemblies have been compiled with .NET Framework 4.5.2, but CRM Developer Toolkit was compiled using NET Framework 4.5. See the next Microsoft article for more details.
For instance, let’s check the new assembly Microsoft.xrm.sdk.dll part of the CRM SDK 2015:
The good news are… we still can make compatible the Developer Toolkit with the latest CRM SDK 2015 editing the .NET Framework in the corresponding projects of our Visual Studio solution. Let’s say we have the next CRM solution:
For plugins and workflows, we should update the references to the new assemblies and also the .NET Framework in the project properties:
After updating those references, we could still find the following error:
“The type or namespace name ‘Xrm’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?)”
This error is indicating you haven’t got installed the expected .NET Framework 4.5.2. Do right click on the same project and select Properties to check the version actually used:
If you are only getting old versions of the Target Framework, select “Install other frameworks…” that will take you to the next site:
There you must download .NET Framework 4.5.2 Developer Pack.
After it has been installed, you get a new option in that previous list:
Finally, we need to do something similar with the CRM Package Project. But in this case, we will have to edit the project file and update the entry “TargetFrameworkVersion” to “4.5.2”. Start unloading the project:
Update the mentioned entry “TargetFrameworkVersion“:
Finally, reload the project again and everything should work now!
About this last part, I would like to say thanks to my CRM MVP colleague Scott Durow (@), who helped me to find that entry.
If you don’t update the package project, it may still compiled, but the actual deployment will fail and you should see the next warning in the Visual Studio output:
warning MSB3274: The primary reference “[Your Assembly Name].dll” could not be resolved because it was built against the “.NETFramework,Version=v4.5.2” framework. This is a higher version than the currently targeted framework “.NETFramework,Version=v4.5”
warning MSB3275: The primary reference “[Your Assembly Name].dll” could not be resolved because it has an indirect dependency on the assembly “Microsoft.Xrm.Sdk, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35” which was built against the “.NETFramework,Version=v4.5.2” framework. This is a higher version than the currently targeted framework “.NETFramework,Version=v4.5”
Last week we got a couple of new releases for Microsoft Dynamics CRM 2011: Update Rollup 10 and SDK 5.0.12
Update Rollup 10:
- Windows 8 / Internet Explorer 10 / Office 2013 Preview compatibility
- Many performance and stability-related fixes, including fixes to the CRM Client for Microsoft Outlook
- Contains all hotfixes / updates originally scheduled for release via Update Rollup 9
- Quick Find performance optimizations and EnableRetrieveMultipleOptimization SQL query performance optimizations:
- The Update Rollup 10 Microsoft Download Center page (on August 16th, 2012)
- The Microsoft Update Catalog (on Sept. 11th, 2012)
- The Microsoft Update detection / installation process (on Sept. 11th, 2012)
Some important notes:
- Update Rollup 9 will not be released publically because of a delay in the Q2 Service Update
- Update Rollup 10 is cumulative
- Update Rollup 10 Build number: 5.0.9690.2730
- Prerequisite: Update Rollup 6 installed (build 5.0.9690.1992)
You can find a full summary in the next post from Dynamics CRM in the Field blog:
Some of the features (all details in the Release History section):
- Updated assemblies for Microsoft Dynamics CRM 2011 Update Rollup 10.
- A new Form Scripting Quick Reference that provides simple explanations and examples of the Xrm.Page object methods on a single page.
- Updated the information on Best Practices about service channel allocation performance
- A new topic called Choose your Development Style for Managed Code that describes the choices of tools and classes you can use when you write managed code and provides information to help you decide what is best for your needs.
- A new topic called Create Accessible Web Resources that provides an introduction to creating web resources that offer equivalent functionality for all users so that people with disabilities will be able to use your web resources.
- Added information about quick find query optimizations and a new property “IsQuickFindFilter” in the FilterExpression class to provide consistency between Query Expression and Fetch XML queries
- Improved authentication helper code and a new sample that demonstrates how to connect to the web services without using helper code.
- Added information about enabling IFRAME communication across domains and use window.postMessage
- Code changes to work in browsers to be supported in a later release, and information to guide you in making those changes.
- Added information about how to manage solution files in source code control using the new SolutionPackager tool
- Using the metadata diagram tool for creating entity model diagrams
- How to authenticate and do basic operations from Java
Some important notes:
- SDK Version 5.0.11 has been skipped