从文件解析插件配置文件时出错

An error occurred while parsing the plugin profile from file

我将 CRM 与 CRM SDK 2016 的 插件注册工具 连接,每当我将下载的错误日志文件上传到调试器时,它显示 "An error occured while parsing the plugin's profile from file" 任何人都可以告诉我哪里出错了。图片如下:

ErrorImage

Unhandled Exception: System.ArgumentException: Unable to parse the OrganizationServiceFault. Parameter name: serializedReport at PluginProfiler.Library.ProfilerUtility.ExtractReport(String serializedReport) at PluginProfiler.Library.ProfilerUtility.DeserializeProfilerReport(String assemblyFilePath, String logFilePath, Boolean isCrmDataStream) at PluginProfiler.Library.ProfilerExecutionUtility.RetrieveReport(String logFilePath, Boolean isCrmDataStream) at Microsoft.Crm.Tools.PluginRegistration.CommonControls.Helper.ParseReportOrShowError(Window window, FileBrowserView profilePathControl, Boolean requireReportParse, ProfilerPluginReport& report) Inner Exception: System.InvalidOperationException: Message does not contain a serialized value. at PluginProfiler.Library.ProfilerUtility.ExtractReportFromFault(OrganizationServiceFault fault) at 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 但问题仍然存在。

谢谢。

我建议您执行以下步骤:

  1. 注销插件程序集和 Profiler
  2. 下载最新的365 SDK
  3. 使用来自最新 SDK 的新 PRT 重新注册程序集
  4. 安装 Profiler 并重试
  5. 最重要 - 您共享的错误日志不能用于使用 Profiler 进行调试。会不一样