OrganizationServiceProxy is null

The CrmServiceClient class is a key component of the Xrm Tooling library. This class has two important properties that, as a developer, you may have probably used in many instances: OrganizationServiceProxy and OrganizationWebProxyClient . Depending on the authentication type, these objects may be null. This article explains some of these cases.

Let’s have a look at this code:

https://github.com/rtebar/Dynamics-Utils/blob/master/Dynamics.Utils/Dynamics.Utils.Tests/CrmServiceClientProxies.cs

In this case, using the Office365 authentication type, we have that the OrganizationServiceProxy is not null, but OrganizationWebProxyClient is null.

Now the important news, you must NOT use OrganizationServiceProxy any more in your new implementations. The reason for this is that the authetication type “Office365” has been deprecated:

Effective February 4, 2020, the WS-Trust authentication type that is used by custom clients to connect to Common Data Service is deprecated. This change affects applications that utilize Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy and Microsoft.Xrm.Tooling.Connector.CrmServiceClient classes for the authentication type of “Office365”

https://docs.microsoft.com/en-us/power-platform/important-changes-coming#deprecation-of-office365-authentication-type-and-organizationserviceproxy-class-for-connecting-to-common-data-service

What authentication types should I use? You should use “ClientSecret” or “OAuth” instead. Let’s have a look at these examples:

https://github.com/rtebar/Dynamics-Utils/blob/master/Dynamics.Utils/Dynamics.Utils.Tests/CrmServiceClientProxies.cs

In this other scenario where we are using the Client Secret authentication, we got the opposite, OrganizationServiceProxy is null, but OrganizationWebProxyClient is not null.

The same happens using OAuth:

https://github.com/rtebar/Dynamics-Utils/blob/master/Dynamics.Utils/Dynamics.Utils.Tests/CrmServiceClientProxies.cs

These are three of the most common authentication types used for online deployments. However, there are a few more types, see the common data service connection strings documentation.

The following table sumarise the cases we have discussed above. What about the rest? I’ll wait for your feedback 🙂

OrganizationServiceProxyOrganizationWebProxyClient
Office365Not nullNull
ClientSecretNullNot null
OAuthNullNot null
AD, IFD, CertificateTBCTBC

Notes:

  • Some of the points described in this article are not something new. James Wood (@sirjameswood) already published a good article in the past covering the same topic.
  • At the time of writing this article, I’m using the package Microsoft.CrmSdk.XrmTooling.CoreAssembly 9.1.0.38 and I’m connecting to an environment whose version is 9.1.0.14744 with 2020 release wave 1 enabled

One thought on “OrganizationServiceProxy is null

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s