Thursday, December 15, 2016

Migrating apps from Microsoft.Xrm.Client to Microsoft.Xrm.Tooling

Original Post is here

Today I had a task to migrate couple of apps that used Microsoft.Xrm.Client assemblies to new Tooling assemblies. In this article I will describe steps to use to migrate your own apps to use latest (and recommended) tools to connect to your CRM Instances from code.
Let’s assume that we have an application that uses Microsoft.Xrm.Client assembly to connect to CRM and it stores connection string to CRM in app.config file as it shown on following screenshots:
App1
App2
Also I assumed that NuGet (and not your local hard drive) was as a source for referenced assemblies. To start migration open “Manage NuGet Pakages…” dialog:
App3
Update (if it is required) SDK assemblies to use latest versions available:
App4
Uninstall Microsoft.CrmSdk.Extension package:
App5
Install latest tooling package:
App6
After all operations list of your NuGet packages should look like following:
App7
Following change should be applied to code – removal of references to namespaces Microsoft.Xrm.Client and Microsoft.Xrm.Client.Services and changing of code for getting of service instance from
to
with adding of reference to Microsoft.Xrm.Tooling.Connector namespace.
Don’t forget to change your connection string according to this article.
If your code throws exception like
An unhandled exception of type ‘System.TypeLoadException’ occurred in Microsoft.Xrm.Tooling.Connector.dll Additional information: Could not load type ‘Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior’ from assembly ‘Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.13.8.999, Culture=neutral, PublicKeyToken=31bf3856ad364e35’.
open installed NuGet packages and downgrade Microsoft.IndentityModel.Client.ActiveDirectory to 2.28.3 version:
App8
After that your code should work fine:
App9

No comments:

Post a Comment