Я пытаюсь заполнить поле в объекте пользователя системы всякий раз, когда пользователь создает учетную запись. Я продолжаю получать ошибки при попытке получить объект пользователя системы, чтобы я мог заполнить его атрибуты. Мой код выглядит следующим образом:
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, версия = 2.1.0.1, культура = нейтральная, PublicKeyToken = null» или одна из ее зависимостей. Система не может найти указанный файл.
Может кто-нибудь объяснить, как получить системного пользователя, чтобы я мог обновить его атрибуты?