Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a solution and two projects in it: VisualWebPart and ProjectsLibrary

VisualWebPart has a reference to ProjectsLibrary (tried to change Property for ProjectsLibrary Copy Local to false/true , but it didn't help). Solution deploys without mistakes, then i press button on my VisualWebPart which calls class from my ProjectsLibrary and mistake appears:

<------------------
Server Error in '/' Application.

Could not load file or assembly 'ProjectsLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e73044c0c1e01d59' 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 'ProjectsLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e73044c0c1e01d59' 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 'ProjectsLibrary, Version=1.0.0.0, Culture=neural, PublicKeyToken=e73044c0c1e01d59' or one of its dependencies. The system cannot find the file specified.]
   CompassPlus__Rights.UploadDoc.UploadDocUserControl.Upload_Click(Object sender, EventArgs e) +0
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981

Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456 

----------------->

It happens everytime I try to connect to external library.

Target platform for both projects is x64, solution's active platform is x64. Framework 3,5. Why cant sharepoint2010 or VS2010 find external dll?

share|improve this question
    
@C.Marius i reverted your edits since I had already edited it before you. You probably opened it for edit before me so my edits was overwritten when you saved your edits. If you feel further editing is needed you will have to do it again I'm afraid ;-) –  Anders Rask May 18 '12 at 11:21
    
@AndersRask : I believe it is fine as edited by you! Thank you for the message though! –  C. Marius - MVP May 18 '12 at 13:02
add comment

2 Answers

up vote 3 down vote accepted

If the assembly you reference is really external, you have to include the external DLL in your SharePoint solution package:

In VS open Package > Advanced > Additional Assemblies > Add

Here you must add the assembly and specify the safe controls that will be added to web.config to allow safe parser to execute the assembly

share|improve this answer
    
Appreciated so much! –  Lena May 18 '12 at 11:12
    
If it solved it, please mark as answer so other people knows this –  Anders Rask May 18 '12 at 11:17
add comment

You need to ensure that Visual Studio 2010 project also deploys the other assembly. If you add the other project as a reference to the web part one, VS should include in into the Package. Otherwise you need to do it manually via:

  1. Open your Package Click on "Advanced" (on the bottom)
  2. Add your external DLL
  3. Optionally the Web Part must be also be added in the SafeControls in the web.config, which by default gets added by VS2010, but if you updated the namespace, class name of your web part you might need to locate the .webpart file and update accordingly. Also make sure that the elements.xml reference for SafeControls is updated accordingly to your class name.
share|improve this answer
    
That works for me!!! –  Lena May 18 '12 at 11:13
1  
Thank you for confirming, glad it helped! As recomanded by Anders, mark the appropriate answer to benefit others too! –  C. Marius - MVP May 18 '12 at 13:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.