I recently did an investigation into using Silverlight 2 with Microsoft CRM 4.0. I have posted the resulting project and supporting documentation on Code Gallery. See Microsoft Dynamics CRM 4.0 On Premise Silverlight 2 Bar Chart Sample.
Unlike many code samples you may find, this one includes full step-by-step instructions about building and deploying the sample. It is more like a hands-on-lab. This sample leverages the work done by Humberto Lezama Guadarrama in his post Sample:Silverlight 2 and CRM.
This sample explores the following tasks:
- Using the Asynchronous methods required by Silverlight
- Establishing CRM Authentication
- Using Silverlight Toolkit Chart controls
Using the Asynchronous methods required by Silverlight
One of the things this sample explores is how to use the proxy generated by Visual Studio 2008 for Microsoft CRM 4.0 web services. This is a bit complicated because Silverlight doesn’t allow for synchronous Web service calls – and the Microsoft CRM SDK doesn’t document the use of asynchronous web services calls. When you create the reference to the Web service in Visual Studio 2008 you don’t get a standard CrmService object, you get a CrmServiceSoapClient object which only exposes the asynchronous messages.
Testing indicates that with one notable exception the asynchronous versions of the methods appear to work as expected. One known problem is that the RetrieveMultipleAsync method may return null values. The work around for this is to use the ExecuteAsync method on an RetrieveMultipleRequest that is configured to return Dynamic Entities. This sample shows how this works.
Establishing CRM Authentication
As detailed in Humberto Lezama Guadarrama’s post Silverlight 2 and CRM, it is necessary to provide a mechanism to inject a custom CRM Authentication token into the SOAP headers generated by the proxy. This sample uses the same technique.
Using Silverlight Toolkit Chart controls
Finally, when creating this sample I was looking for a way to use Silverlight within Microsoft CRM without writing a complete CRM UI. The Silverlight Toolkit provides some useful components to build charts. Since these could be hosted within a CRM IFrame or launched like a report from a custom button – I chose to use those.
If you are interested in trying Silverlight in the context of Microsoft CRM, I hope this sample helps you.