无法加载文件或程序集''或其依赖项之一

Imi*_*xha 17 c# asp.net sharepoint sharepoint-2010

有什么帮助吗?

我只有一个图书馆,这让我发疯.这是我收到的错误.我没有使用任何其他依赖.

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
Run Code Online (Sandbox Code Playgroud)

Ole*_*yev 28

要使Visual Studio从解决方案中的其他项目向GAC添加第三方程序集甚至您自己的程序集,请执行下一步:

  1. 从SharePoint项目中的Package文件夹中打开Package.package.

  2. 单击底部区域中的"高级"

  3. 单击"添加",然后选择要添加的程序集类型.

  4. 在对话框中选择dll文件,chec GAC或BIN,如果需要,添加安全控件和类资源条目.单击确定.

您的程序集将打包到WSP,在清单中定义并每次部署.


Imi*_*xha 16

问题解决了!

我认为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中.

感谢您的支持.