简体   繁体   English

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

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

Any help please? 有什么帮助吗?

I have only one library and it is driving me crazy. 我只有一个图书馆,这让我发疯。 this is the error that I receive. 这是我收到的错误。 I am not using any other dependancies. 我没有使用任何其他依赖。

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

To make Visual Studio adding 3rd party assembly or even your own assembly from other project in solution to GAC please do next: 要使Visual Studio从解决方案中的其他项目向GAC添加第三方程序集甚至您自己的程序集,请执行下一步:

  1. Open Package.package from Package folder in SharePoint project. 从SharePoint项目中的Package文件夹中打开Package.package。

  2. Click Advanced in bottom area. 单击底部区域中的“高级”

  3. Click Add and chose which type of assembly you want to add. 单击“添加”,然后选择要添加的程序集类型。

  4. In dialog select dll file, chec GAC or BIN, add safe controls and class resources entries if required. 在对话框中选择dll文件,chec GAC或BIN,如果需要,添加安全控件和类资源条目。 Click Ok. 单击确定。

Your assembly will be packaged to WSP, defined in manifest and deployed everytime. 您的程序集将打包到WSP,在清单中定义并每次部署。

Problem Solved! 问题解决了!

I thought that Visual Studio was copying the DLL in to the GAC, but apparently not. 我认为Visual Studio正在将DLL复制到GAC中,但显然不是。 So I copied it there manually and it works. 所以我手动复制它,它的工作原理。

One question though, is this normal that visual studio does not copy it to the GAC when I deploy the sharepoint application? 但有一个问题是,在部署sharepoint应用程序时,Visual Studio不会将其复制到GAC这是正常的吗?

For those who would like to know how to copy the dll to GAC 对于那些想知道如何将dll复制到GAC的人

there are two ways to copy the dll to GAC: 有两种方法可以将dll复制到GAC:

  1. copy the dll manually 手动复制DLL

    1. Open c:\\windows\\assembly directory in windows explorer 在Windows资源管理器中打开c:\\ windows \\ assembly目录
    2. Open another instance of windows explorer and go to the place where your dll is located, usually in the bin folder. 打开另一个Windows资源管理器实例,然后转到dll所在的位置,通常位于bin文件夹中。 (so now you will have two windows open) (所以现在你将打开两个窗户)
    3. select the dll you would like to copy to gac and drag it inside the assembly directory, c:\\windows\\assembly 选择要复制到gac的dll并将其拖到程序集目录c:\\ windows \\ assembly中
  2. use VS to deploy it for you to GAC. 使用VS将其部署到GAC。

    1. in your sharepoint project double click on "Package". 在您的sharepoint项目中双击“Package”。
    2. Package.Package will open. Package.Package将打开。 Look bottom left of your screen and click on "Advanced", 查看屏幕左下角,然后点击“高级”,
    3. then click on "Add", then select "Add Assembly from project output...". 然后单击“添加”,然后选择“从项目输出中添加组件...”。
    4. In the Source project dropdownlist select the project and then click OK. 在“源项目”下拉列表中,选择项目,然后单击“确定”。
    5. finally deploy the solution and the dll will be in the GAC. 最后部署解决方案,dll将在GAC中。

thank you for your support. 感谢您的支持。

For assemblies not in GAC, and which are referred in the build, sometimes this error also happens if the platform target does not match. 对于不在GAC中的程序集以及在构建中引用的程序集,如果平台目标不匹配,有时也会发生此错误。 So match the assembly platform type to the one where it is being used. 因此,将装配平台类型与正在使用的类型匹配。

在此输入图像描述

If error is when publishing in Visual Studio 2012 un-check the "Precompile during publishing" option in the publish wizard and try again. 如果在Visual Studio 2012中发布时出错,请在发布向导中取消选中“发布期间预编译”选项,然后重试。

取消选中“发布期间预编译”框

for guys still looking into this issue one thing u need to know is there are different GACutils out there , so u need to make sure that ur using correct GACUTIL to deploy the DLL to correct GAC 对于仍然在研究这个问题的人来说,你需要知道的是有一些不同的GACutils,所以你需要确保你使用正确的GACUTIL部署DLL来纠正GAC

for eg: if my dll was complied in 3.5 .net framework and my OS version was 64 bit windows it would be in below location 例如:如果我的dll符合3.5 .net框架,我的操作系统版本是64位窗口,它将在下面的位置

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

Struggled for 4 stupid days to figure this out 苦苦挣扎了4个愚蠢的日子来解决这个问题

  • Does the version number match? 版本号是否匹配?
  • It's weird to see you're trying to load a .lib file instead of a dll. 看到你试图加载.lib文件而不是dll是很奇怪的。 Perhaps you wanted to load a dll instead? 也许你想加载一个DLL而不是?
  • To debug this kind of problems, try Fusion Logging 要调试此类问题,请尝试Fusion Logging
  • You say you're using only one library, but that library might have some dependencies you're not aware of. 您说您只使用一个库,但该库可能有一些您不知道的依赖项。 This SO question deals with listing the dependencies of a managed .NET assembly. 这个问题涉及列出托管.NET程序集的依赖关系。

Please try to unreference the DLL then re reference it again and rebuild you project. 请尝试取消引用DLL然后再次引用它并重建项目。 Also Check to ensure that the version matchs what is in the project web config 还要检查以确保版本与项目Web配置中的版本匹配

Assuming that you have access to SharePoint server, try the following. 假设您有权访问SharePoint服务器,请尝试以下操作。 Some random thoughts and no specific order. 一些随机的想法,没有具体的顺序。

  • Deploy the assembly to GAC or copy the dll to the bin folder of your web application 将程序集部署到GAC或将dll复制到Web应用程序的bin文件夹
  • Add the assembly info in your web.config assemblies section and in the safe controls section. 在web.config程序集部分和安全控件部分中添加程序集信息。
  • If you are developing a web part, make sure to add its reference in the safe controls section of the web parts (although i don't think this is your problem) 如果您正在开发Web部件,请确保在Web部件的安全控件部分添加其引用(尽管我不认为这是您的问题)
  • Signing the assembly with a strong name might help in some cases. 在某些情况下,使用强名称对程序集进行签名可能会有所帮助。
  • If you have custom dependencies then you need to do the follow the same steps for all the dependencies (other than .net framework and SharePoint related) 如果您有自定义依赖项,则需要对所有依赖项执行相同的步骤(除了.net框架和SharePoint相关)

Are you developing your SharePoint project (do you mean web part?) using visual studio? 您是否正在使用visual studio开发SharePoint项目(您的意思是Web部件吗?)? Are you referencing it in your SharePoint project? 您是否在SharePoint项目中引用它? You need to give us more details on your development environment to be able to pinpoint the problem. 您需要向我们提供有关开发环境的更多详细信息,以便能够查明问题。

If you are using the code Page.Load("control_path..."). 如果您使用的是代码Page.Load(“control_path ...”)。 make sure that the actual ascx file you load does not have any directives that include the assembly from your exception message 确保您加载的实际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.

相关问题 无法加载文件或程序集及其依赖项之一 - Could not load file or assembly and one of its dependencies 无法加载文件或程序集或其依赖项之一 - Could not load file or assembly or one of its dependencies 无法加载文件或程序集或其依赖项之一 - could not load file or assembly or one of its dependencies 无法加载文件或程序集或其依赖项之一 - Could not load file or assembly or one of its dependencies 无法加载文件或程序集“ xxxLib”或其依赖项之一。 BadImageFormatException - Could not load file or assembly 'xxxLib' or one of its dependencies. BadImageFormatException 无法加载文件或程序集“ BookMe”或其依赖项之一 - Could not load file or assembly 'BookMe' or one of its dependencies 无法加载文件或程序集“Elasticsearch.Net”或其依赖项之一 - Could not load file or assembly 'Elasticsearch.Net' or one of its dependencies 无法加载文件或程序集“ Newtonsoft.Json”或其依赖项之一? - Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies? 无法加载文件或程序集“FreeTextBox”或其依赖项之一 - Could not load file or assembly 'FreeTextBox' or one of its dependencies 无法加载文件或程序集或其依赖项之一。 - Could not load file or assembly or one of its dependencies.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM