Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 572
Imir Hoxha Avatar asked Dec 06 '11 20:12

Imir Hoxha


People also ask

Could not load file or assembly Could not load file or assembly?

In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.

Could not load file or assembly or one of its dependencies DLL?

There are some workarounds for this issue: The dll file may not be in /bin folder. Just copy the dll file to /bin folder or set this preference Copy Local = True from Visual Studio. If the problem persists, check if the version of the assembly that is referenced is different than the version it is looking for.

Could not load file or assembly Publickeytoken null or one of its dependencies?

This error usually means that the assembly was not found. Try verifying that the file exists in the directory where your application is running.

Could not load file or assembly attempt was made to load a program with an incorrect format?

“An attempt was made to load a program with an incorrect format.” That means that the assembly, which was to be loaded, was in an unexpected format. The format, in this case, refers most likely to the 64-bit build of an application being deployed to IIS, which is being run in 32-bits.


2 Answers

To make Visual Studio adding 3rd party assembly or even your own assembly from other project in solution to GAC please do next:

  1. Open Package.package from Package folder in SharePoint project.

  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. Click Ok.

Your assembly will be packaged to WSP, defined in manifest and deployed everytime.

like image 57
Oleg Savelyev Avatar answered Oct 04 '22 08:10

Oleg Savelyev


Problem Solved!

I thought that Visual Studio was copying the DLL in to the GAC, but apparently not. 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?

For those who would like to know how to copy the dll to GAC

there are two ways to copy the dll to GAC:

  1. copy the dll manually

    1. Open c:\windows\assembly directory in windows explorer
    2. Open another instance of windows explorer and go to the place where your dll is located, usually in the bin folder. (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
  2. use VS to deploy it for you to GAC.

    1. in your sharepoint project double click on "Package".
    2. Package.Package will open. 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.

thank you for your support.

like image 32
Imir Hoxha Avatar answered Oct 04 '22 08:10

Imir Hoxha