簡體   English   中英

無法加載文件或程序集''或其依賴項之一

[英]Could not load file or assembly '' or one of its dependencies

有什么幫助嗎?

我只有一個圖書館,這讓我發瘋。 這是我收到的錯誤。 我沒有使用任何其他依賴。

Could not load file or assembly 'FOD.Intranet.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=039c1f3a4c719e82' or one of its dependencies. The system cannot find the file specified. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'FOD.Intranet.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=039c1f3a4c719e82' or one of its dependencies. The system cannot find the file specified.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[FileNotFoundException: Could not load file or assembly 'FOD.Intranet.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=039c1f3a4c719e82' or one of its dependencies. The system cannot find the file specified.]
   NewCollection.VisualWebPart1.VisualWebPart1UserControl.TodaysNews() +0
   NewCollection.VisualWebPart1.VisualWebPart1UserControl.Page_Load(Object sender, EventArgs e) +52
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +350
   NewCollection.VisualWebPart1.VisualWebPart1.CreateChildControls() +155
   System.Web.UI.Control.EnsureChildControls() +146
   System.Web.UI.Control.PreRenderRecursiveInternal() +61
   System.Web.UI.Control.PreRenderRecursiveInternal() +224
   System.Web.UI.Control.PreRenderRecursiveInternal() +224
   System.Web.UI.Control.PreRenderRecursiveInternal() +224
   System.Web.UI.Control.PreRenderRecursiveInternal() +224
   System.Web.UI.Control.PreRenderRecursiveInternal() +224
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

要使Visual Studio從解決方案中的其他項目向GAC添加第三方程序集甚至您自己的程序集,請執行下一步:

  1. 從SharePoint項目中的Package文件夾中打開Package.package。

  2. 單擊底部區域中的“高級”

  3. 單擊“添加”,然后選擇要添加的程序集類型。

  4. 在對話框中選擇dll文件,chec GAC或BIN,如果需要,添加安全控件和類資源條目。 單擊確定。

您的程序集將打包到WSP,在清單中定義並每次部署。

問題解決了!

我認為Visual Studio正在將DLL復制到GAC中,但顯然不是。 所以我手動復制它,它的工作原理。

但有一個問題是,在部署sharepoint應用程序時,Visual Studio不會將其復制到GAC這是正常的嗎?

對於那些想知道如何將dll復制到GAC的人

有兩種方法可以將dll復制到GAC:

  1. 手動復制DLL

    1. 在Windows資源管理器中打開c:\\ windows \\ assembly目錄
    2. 打開另一個Windows資源管理器實例,然后轉到dll所在的位置,通常位於bin文件夾中。 (所以現在你將打開兩個窗戶)
    3. 選擇要復制到gac的dll並將其拖到程序集目錄c:\\ windows \\ assembly中
  2. 使用VS將其部署到GAC。

    1. 在您的sharepoint項目中雙擊“Package”。
    2. Package.Package將打開。 查看屏幕左下角,然后點擊“高級”,
    3. 然后單擊“添加”,然后選擇“從項目輸出中添加組件...”。
    4. 在“源項目”下拉列表中,選擇項目,然后單擊“確定”。
    5. 最后部署解決方案,dll將在GAC中。

感謝您的支持。

對於不在GAC中的程序集以及在構建中引用的程序集,如果平台目標不匹配,有時也會發生此錯誤。 因此,將裝配平台類型與正在使用的類型匹配。

在此輸入圖像描述

如果在Visual Studio 2012中發布時出錯,請在發布向導中取消選中“發布期間預編譯”選項,然后重試。

取消選中“發布期間預編譯”框

對於仍然在研究這個問題的人來說,你需要知道的是有一些不同的GACutils,所以你需要確保你使用正確的GACUTIL部署DLL來糾正GAC

例如:如果我的dll符合3.5 .net框架,我的操作系統版本是64位窗口,它將在下面的位置

C:\\ Program Files(x86)\\ Microsoft SDKs \\ Windows \\ v7.0A \\ Bin \\ x64

苦苦掙扎了4個愚蠢的日子來解決這個問題

  • 版本號是否匹配?
  • 看到你試圖加載.lib文件而不是dll是很奇怪的。 也許你想加載一個DLL而不是?
  • 要調試此類問題,請嘗試Fusion Logging
  • 您說您只使用一個庫,但該庫可能有一些您不知道的依賴項。 這個問題涉及列出托管.NET程序集的依賴關系。

請嘗試取消引用DLL然后再次引用它並重建項目。 還要檢查以確保版本與項目Web配置中的版本匹配

假設您有權訪問SharePoint服務器,請嘗試以下操作。 一些隨機的想法,沒有具體的順序。

  • 將程序集部署到GAC或將dll復制到Web應用程序的bin文件夾
  • 在web.config程序集部分和安全控件部分中添加程序集信息。
  • 如果您正在開發Web部件,請確保在Web部件的安全控件部分添加其引用(盡管我不認為這是您的問題)
  • 在某些情況下,使用強名稱對程序集進行簽名可能會有所幫助。
  • 如果您有自定義依賴項,則需要對所有依賴項執行相同的步驟(除了.net框架和SharePoint相關)

您是否正在使用visual studio開發SharePoint項目(您的意思是Web部件嗎?)? 您是否在SharePoint項目中引用它? 您需要向我們提供有關開發環境的更多詳細信息,以便能夠查明問題。

如果您使用的是代碼Page.Load(“control_path ...”)。 確保您加載的實際ascx文件沒有包含異常消息中的程序集的任何指令

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM