ICrmService and IMetadataService in RC0
Friday, November 23, 2007 at 12:46AM Looks like there was a small change for the good on the return types for IPluginContext.CreateCrmService and CreateMetadataService. In CTP3, these used to return an object and you used to have to cast it to a CrmService object to use it. The following is an example from the SDK...
CrmService service = (CrmService)context.CreateCrmService(true);
This created a few different problems most of them flexibility around what object is being returned. If CreateCrmService ever returned an object of a different type, you would either get a null or a cast exception.
Now with it returning an interface ICrmService you should be able to do the following...
ICrmService service = context.CreateCrmService(true);
Notice I don't do the cast, I reference it via the interface and by doing that I really don't care what the actual class type that is returned by the create is.
Applause for the CRM team, this is one I had asked for and didn't think would make it in for RTM - Good Job!

Reader Comments