CRm Dynamics 2013插件错误,请求xxx类型的权限失败
本文关键字:类型 xxx 权限 失败 请求 Dynamics 2013 插件 错误 CRm | 更新日期: 2023-09-27 18:22:44
我有一个CRM插件,它在更新表单上的字段时启动,然后插件应该利用SDK的导入功能将CSV记录导入Dynamics,我得到以下错误
请求类型的权限'System.Security.Permissions.FileIOPermission,mscorlib,版本=4.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089'失败。
我已经在隔离模式下注册了插件,设置为NONE,而不是Sandbox,但我仍然收到了错误,关于为什么会发生这种情况以及如何解决它的任何想法。它在ImportData函数中封装的ImportFile部分失败。
请参阅下方的插件代码
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context == null)
{
throw new ArgumentNullException("loaclContext");
}
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity supplyClaimsEntity = (Entity)context.InputParameters["Target"];
if (supplyClaimsEntity.LogicalName != "new_supplierclaimsupdate")
{
return;
}
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);
string entityBeginUpload = "Start Upload";
try
{
string filePath = (@"C:'Team CRM'Warp.csv");
ImportData(service, new_topproducts.EntityLogicalName, filePath);
}
catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
{
Console.WriteLine("The application terminated with an error.");
Console.WriteLine("Timestamp: {0}", ex.Detail.Timestamp);
Console.WriteLine("Code: {0}", ex.Detail.ErrorCode);
Console.WriteLine("Message: {0}", ex.Detail.Message);
Console.WriteLine("Inner Fault: {0}",
null == ex.Detail.InnerFault ? "No Inner Fault" : "Has Inner Fault");
}
catch (System.TimeoutException ex)
{
Console.WriteLine("The application terminated with an error.");
Console.WriteLine("Message: {0}", ex.Message);
Console.WriteLine("Stack Trace: {0}", ex.StackTrace);
Console.WriteLine("Inner Fault: {0}",
null == ex.InnerException.Message ? "No Inner Fault" : ex.InnerException.Message);
}
catch (System.Exception ex)
{
Console.WriteLine("The application terminated with an error.");
Console.WriteLine(ex.Message);
// Display the details of the inner exception.
if (ex.InnerException != null)
{
Console.WriteLine(ex.InnerException.Message);
FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> fe = ex.InnerException
as FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>;
if (fe != null)
{
Console.WriteLine("Timestamp: {0}", fe.Detail.Timestamp);
Console.WriteLine("Code: {0}", fe.Detail.ErrorCode);
Console.WriteLine("Message: {0}", fe.Detail.Message);
Console.WriteLine("Trace: {0}", fe.Detail.TraceText);
Console.WriteLine("Inner Fault: {0}",
null == fe.Detail.InnerFault ? "No Inner Fault" : "Has Inner Fault");
}
}
}
假设这是一个同步插件(异步插件可能在不同的服务器上运行,具体取决于您的部署),请检查用户运行的IIS帐户是否拥有该文件夹的权限。如果没有,那么您将看到文件权限错误。
您是否在在线组织上运行该插件?在这种情况下,注册程序集时无法将组织设置为模式。