I have a C# workflow that I’m trying to create an IOrganzationService in that has the proxy types enabled on it so I can use my early bound data types…
This is how I’m creating the IOrganizationSerivce
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
But since I don’t have an OrganizationServiceProxy object, I can’t call EnableProxyTypes() on the service, and any create calls on the service using an early bound entity fails.
I know I can revert to setting the server url url, sdk server url, and organization in the app.config and use that to create an OrganizationServiceProxy but it seems like I should be able to just set the EnableProxyTypes on the IOrganizationService that I already have…
Update
I believe this was a bug in 2011 and maybe 2013 that has long since been resolved. See Jim’s answer with a link as to why you should not be using the accepted answer for 2015 or newer instances.
To be able to use the early bound entities in the context of an workflow try the following snippet:
As you can see there is a property named
ProxyTypesAssemblythat specifies the assembly where you keep the early bound entities. The only way i could set this property was using reflection because theWorkflowContextBase(the base class ofWorkflowContext) was not accessible.