2014-11-17 44 views
0

所以我嘗試訪問我的SharePoint 2013的TermStore我嘗試做這樣的:無法打開的SPSite - FileNotFoundException異常

 SPSecurity.RunWithElevatedPrivileges(() => 
     { 
      var site = new SPSite(GeneralConstants.TermStoreUrl); 

      try 
      { 

       // Get a TaxonomySession from the site 
       TaxonomySession session = new TaxonomySession(site); 
       TermStore termStore = null; 
       // Get a TermStore from the session 
       if (session.TermStores != null && session.TermStores.Count > 0) 
       { 
        termStore = session.TermStores[0]; 
       } 

       if (termStore != null) 
       { 
        //... do stuff in TermStore 

的問題是,當我創建的SPSite,我得到一個FileNotFoundException。這裏有什麼問題? 當我在瀏覽器中檢查URL時,它工作正常,應用程序運行的用戶,順便說一句web服務,完全控制網站。

感謝您的幫助 電賀

+0

你有沒有通過代碼..?你能找出哪一行沒有工作..?你也有部分代碼,你可以顯示與這個問題有關的所有相關代碼..?也檢查這個博客它也許幫助http://www.mikhaildikov.com/2007/07/runwithelevatedprivileges-watch-out-for.html – MethodMan

+0

你正在做什麼樣的程序? WebPart? WinForm? WPF?頁面? APP?控制檯程序? – Max

回答

0

感謝您的答案,但我發現了錯誤。我使用了Sharepoint.Taxonomy命名空間而不是Sharepoint。 客戶端。分類

現在我工作正常。

0

您是否嘗試過訪問您的TaxonomySession的DefaultSiteCollectionTermStore財產?

var session = new TaxonomySession(site); 
TermStore termStore = session.DefaultSiteCollectionTermStore; 

此外,我在SP管理窗口中使用PowerShell來調試我的Taxonomy代碼邏輯。它有很多幫助。

相關問題