2

ユーザーがアカウントを作成するたびに、システム ユーザー エンティティのフィールドに入力しようとしています。システム ユーザー エンティティを取得してその属性を設定できるようにしようとすると、エラーが発生し続けます。私のコードは次のとおりです。

public void Execute(IServiceProvider serviceProvider)
        {
            ITracingService tracingservice = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService service = factory.CreateOrganizationService(context.InitiatingUserId);

            if (context.InputParameters.Contains("Target") &&
               context.InputParameters["Target"] is Entity)
            {
                try
                {
                    //Get entity that fired plugin
                    Entity entMain = (Entity)context.InputParameters["Target"];

                    //Make a String for the last activity entity
                    String strLastEntity = "";

                    //Make the entity for the user entity
                    Entity entUser = (Entity)service.Retrieve("systemuser", context.InitiatingUserId, new ColumnSet(new String[] { "new_lastactivityentity" }));

                    //Get the entity type that fired the plugin and set it to the right field for the user entity
                    if (entMain.LogicalName.Equals("account"))
                    {
                        strLastEntity = entMain.LogicalName;
                        entUser["new_lastactivityentity"] = strLastEntity;
                    }
                }
                catch (Exception ex)
                {
                    tracingservice.Trace("FollowupPlugin: {0}", ex.ToString());
                    throw;
                }
            }
        }

エラー: ファイルまたはアセンブリ 'PluginRegistration、Version=2.1.0.1、Culture=neutral、PublicKeyToken=null' またはその依存関係の 1 つを読み込めませんでした。システムは、指定されたファイルを見つけることができません。

属性を更新できるように、システムユーザーを取得する方法を誰かが説明できますか?

4

1 に答える 1