2013-06-06 1 views
2

사용자가 계정을 만들 때마다 시스템 사용자 엔터티에 필드를 채우려고합니다. 그 특성을 채울 수 있도록 시스템 사용자 엔터티를 검색 할 때 오류가 계속 발생합니다. 다음과 같이 내 코드는 다음과 같습니다새 계정 생성시 CRM 2011 업데이트 시스템 사용자

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이'또는 해당 종속성 중 하나. 시스템이 지정된 파일을 찾을 수 없습니다.

시스템 사용자를 얻는 방법을 다른 사람이 설명하여 속성을 업데이트 할 수 있습니까?

답변

0

서버에 설치되지 않은 어셈블리 참조 (특히 PluginRegistration)가 있기 때문입니다.

서버의 GAC에 해당 dll을 배치 할 수 있지만 CRM 온라인 (또는 내가 믿는 샌드 박스 등록)에서는 작동하지 않습니다.

PluginRegistration은 플러그인 등록 도구에 사용 된 Microsoft 어셈블리에 대한 참조입니까? 일반적으로 프로젝트에서 해당 참조를 필요로하지 않으므로 참조를 제거 할 수 있습니다.