I'm writing a stand-alone service (not a plug-in, in the strictest sense) to periodically update Dynamics CRM 2011 using the SDK.
My code includes the following:
// Get entity metadata so we can process attributes correctly
IPluginExecutionContext context = (IPluginExecutionContext)ServiceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)ServiceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
... (etc)
This requires an instance of the ServiceProvider class [which implements IServiceProvider] but I have no idea how to get it.
So, how do I get it?
Thanks
[Edit]
I'm currently looking at using ServerConnection as an alternative.
http://msdn.microsoft.com/en-us/library/gg309393.aspx
[/Edit]