2014-04-16 17 views
5

Tôi đang cập nhật quản lý trường dữ liệu meta bằng C#. Sau đây là mã để lấy TermId cho thuật ngữ.Sharepoint 2013 - Phân loại- Microsoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession ”

 string termId = string.Empty; 

     try 
     { 
      TaxonomySession tSession = TaxonomySession.GetTaxonomySession(CC); 
      TermStore termStore = taxonomySession.GetDefaultSiteCollectionTermStore(); 
      TermSet tset = ts.GetTermSet(termSetId); // I have proper Guid here, checked this in SharePoint 2013 server. 

      LabelMatchInformation lmi = new LabelMatchInformation(CC); 

      lmi.Lcid = 1033; 
      lmi.TrimUnavailable = true; 
      lmi.TermLabel = "xyz"; //Name of the term. 

      TermCollection termMatches = tset.GetTerms(lmi); 

      CC.Load(tSession); 
      CC.Load(ts); 
      CC.Load(tset); 
      CC.Load(termMatches); 
      CC.ExecuteQuery(); 

      if (termMatches != null && termMatches.Count() > 0) 
       termId = termMatches.First().Id.ToString(); 
     } 
     catch (Exception ex) 
     { 
      var d = ex.Message; 
     } 

     return termId; 

    } 

Nhưng tôi nhận được ngoại lệ như: “Không thể gọi phương thức hoặc lấy tài sản từ đối tượng null. Đối tượng được trả về bởi ngăn xếp cuộc gọi sau là null. \ "GetDefaultSiteCollectionTermStore \ r \ nMicrosoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession”.

Tôi đã cố gắng để nạp bằng tay từ Sharepoint2013, nó hoạt động tốt ở đó. Có điều gì thiếu ? Nhờ sự giúp đỡ ..

Trả lời

5

tới dịch vụ siêu dữ liệu được quản lý (trong các ứng dụng dịch vụ trong quản trị trung tâm. Đánh dấu Managed Metadata Service Proxy, và chọn Properties. Đặt rằng việc áp dụng là storeage mặc định cho các từ khóa và cho termsets.

4

tín dụng để user1545314 và google

enter image description here

Các vấn đề liên quan