FIX: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type "Your Entity Class" - Byron Salau

Posted by | October 07, 2013 | c# | One Comment

If you ever come accross this while using the Microsoft Dynamics SDK Proxy

Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type "Your Entity Class"

The solution

Where you create your service proxy instance, make sure you ‘Enable Proxy Types’ (see line 2)

example


OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, null, credentials, null);
orgProxy.EnableProxyTypes();

IOrganizationService service = (IOrganizationService)orgProxy;
  • Marty

    Thanks a bunch, saved me a lot of time :)