App Domain在调试插件时卸载

时间:2013-06-27 07:08:26

标签: dynamics-crm-2011 dynamics-crm dynamics-crm-online

我正在Disassociate Project消息上创建一个插件(自定义实体);与User实体具有N:N关系。它不起作用。这是代码。

        IOrganizationService service = localContext.OrganizationService;
        IPluginExecutionContext context = localContext.PluginExecutionContext;

        // Get Primary Entity
        EntityReference target = (EntityReference)context.InputParameters["Target"];

        if (target.LogicalName == "new_project" || target.LogicalName == "systemuser")
        {
            Relationship relationShip = (Relationship)context.InputParameters["Relationship"];

            // Get Related Entities
            EntityReferenceCollection relatedentities = (EntityReferenceCollection)context.InputParameters["RelatedEntities"];
            foreach (EntityReference rel in relatedentities)
            {
                // Check Related Entity Logical & Schema name
                if (rel.LogicalName == "new_project" && relationShip.SchemaName == "new_systemuser_new_project")
                {
                    Entity user = service.Retrieve("systemuser", target.Id, new ColumnSet(true));
                    Entity project = service.Retrieve("new_project", rel.Id, new ColumnSet(true));

                    // Grant access
                    RevokeAccessRequest revokeAccessRequest = new RevokeAccessRequest
                    {
                       Revokee=target,
                        Target = rel
                    };

                    service.Execute(revokeAccessRequest);
                }
            }
        }

但是我无法使用插件注册工具调试此插件。它返回消息“App Domain Unloaded”。

enter image description here

我不知道这个插件有什么问题。请帮助。

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。 我在更新消息中注册了此插件,然后更改了RegisterFile.crmregister

MessageName="Disassociate"PrimaryEntityName=""

还更改了我的插件类的默认构造函数。

base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(10, "Disassociate", "", new Action<LocalPluginContext>(ExecutePreValidateProjectUpdate)));

希望这能帮助遇到同样问题的人。