动态CRM在线2015自定义工作流程早期绑定错误

时间:2015-06-16 06:10:05

标签: c# dynamics-crm

我从crmsvcutil.exe创建一个XRM.cs文件并引用url

Could not load file or assembly 'Microsoft.Xrm.Client

所以我将'Microsoft.Xrm.Client'与我的工作流程程序集合并在CRM在线服务器的数据库中注册。然后我收到了这个错误:

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Microsoft.Xrm.Sdk.KnownProxyTypesProvider.LoadKnownTypes(Assembly assembly)
at Microsoft.Xrm.Sdk.KnownProxyTypesProvider.RegisterAssembly(Assembly assembly)
at Microsoft.Xrm.Sdk.AssemblyBasedKnownProxyTypesProvider.GetNameForType(Type type)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.CheckEntitySubclass(Type entityType)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.CreateQuery[TEntity]()
at Xrm.XrmServiceContext.get_AccountSet()
at Mailer.SendMailDaily.Execute(CodeActivityContext executionContext)
The action that failed was:
InheritanceDemand
The type of the first permission that failed was:
System.Security.Permissions.UIPermission
The Zone of the assembly that failed was:
MyComputer  

这是我的代码,任何人都可以解决这个问题吗?

IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);
var xrm = new XrmServiceContext(service);
var customers = from c in xrm.AccountSet select c;

1 个答案:

答案 0 :(得分:0)

要明确你的意思是这个微软的程序集?

https://msdn.microsoft.com/en-us/library/microsoft.xrm.client.aspx

你为什么这样做?

只需注册您自己的插件程序集。