每当我将下载的错误日志文件上传到调试器时,我都会将CRM与CRM SDK 2016的插件注册工具连接起来,显示“从文件解析插件的配置文件时出错” 可以建议我哪里出错了。图片如下所示:
未处理的异常:System.ArgumentException:无法解析OrganizationServiceFault。 参数名称:serializedReport 在PluginProfiler.Library.ProfilerUtility.ExtractReport(String serializedReport) 在PluginProfiler.Library.ProfilerUtility.DeserializeProfilerReport(String assemblyFilePath,String logFilePath,Boolean isCrmDataStream) 在PluginProfiler.Library.ProfilerExecutionUtility.RetrieveReport(String logFilePath,Boolean isCrmDataStream) 在Microsoft.Crm.Tools.PluginRegistration.CommonControls.Helper.ParseReportOrShowError(窗口窗口,FileBrowserView profilePathControl,布尔requireReportParse,ProfilerPluginReport& report) 内部异常:System.InvalidOperationException:消息不包含序列化值。 在PluginProfiler.Library.ProfilerUtility.ExtractReportFromFault(OrganizationServiceFault错误) 在PluginProfiler.Library.ProfilerUtility.ExtractReport(String serializedReport)
除此之外,当下载日志文件时,它包含以下错误:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): SamplePlugins.PostCreateContact: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.Detail:
<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ActivityId>8998bfd9-9637-430e-8c47-998c63d1f0ee</ActivityId>
<ErrorCode>-2147220956</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Unexpected exception from plug-in (Execute): SamplePlugins.PostCreateContact: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.</Message>
<Timestamp>2017-11-03T11:49:06.9775603Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText>[SamplePlugins: SamplePlugins.PostCreateContact]
[e326c926-0dbe-e711-a94d-000d3af2242b: SamplePlugins.PostCreateContact: Create of contact (Profiled)]</TraceText>
</OrganizationServiceFault>
以下是 .CS 文件:
using Microsoft.Xrm.Sdk;
using System;
namespace SamplePlugins
{
public class PostCreateContact : IPlugin
{
ITracingService tracingService;
public void Execute(IServiceProvider serviceProvider)
{
tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
tracingService.Trace("Tracing Execute");
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
// The InputParameters collection contains all the data
//passed in the message request.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
try
{
// Create a task activity to follow up with the account customer in 7 days
Entity followup = new Entity("task");
followup["subject"] = "Send e-mail to the new customer.";
followup["description"] = "Follow up with the customer. Check if there are any new issues that need resolution.";
followup["scheduledstart"] = DateTime.Now;
followup["scheduledend"] = DateTime.Now.AddDays(2);
followup["category"] = context.PrimaryEntityName;
// Refer to the contact in the task activity.
if (context.OutputParameters.Contains("id"))
{
Guid regardingobjectid = new Guid(context.OutputParameters["id"].ToString());
string regardingobjectidType = "contact";
followup["regardingobjectid"] = new EntityReference(regardingobjectidType, regardingobjectid);
}
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service =
serviceFactory.CreateOrganizationService(context.UserId);
// Create the followup activity
service.Create(followup);
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(ex.Message);
}
}
}
}
}
我尝试过更换 PluginProfiler.Solution.zip ,但问题仍然存在。
感谢。
答案 0 :(得分:0)
我建议你采取以下步骤: