18

I'm new to SharePoint and trying to get my head around this. I have a simple Web Part project. I also have a custom Data layer project that uses the Microsoft Enterprise Library for data access. In the Web Part project, I am adding a reference to the Data layer project's assembly. I specified in the Package of the Web Part project that I want my Data layer's assembly to be deployed. I can verify this works by using standard ADO.NET classes and not the custom MS library. If I deploy to the SharePoint server (which I have 100% access to) using the Enterprise Library, I get the error message:

"Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data"

What steps do I need to take to ensure this project and all future projects on the server can easily gain access to the Enterprise Library for data access?

Thanks!

Mike
  • 2,912
  • 4
  • 31
  • 52

1 Answers1

34

You did everything correct until a certain point: Deployment.

When deploying external DLLs, which shall also be put into the GAC or somewhere else, you need to package them with the WSP aswell. This has become very easy with Visual Studio 2010:

  1. Open your Package
  2. Click on "Advanced" (on the bottom)
  3. Add your external DLL and maybe even SafeControls for the web.config
Dennis G
  • 21,405
  • 19
  • 96
  • 133
  • Thank you, that worked. One follow-up question though: It appears to deploy to the GAC. Does this mean for future projects, I do not have to package the same dll's over again? – Mike Feb 23 '11 at 17:14
  • Yes, correct. It is deployed in that project - problem is if you retract that solution, the dll is also retracted from the GAC and all your other projects will fail. So either you add it to all projects so it is always deployed - or you create a custom "Deployment" feature, which only provisions this DLL and other stuff you always want to have. – Dennis G Feb 23 '11 at 17:17
  • Thanks! This was a huge help! – MBentley Mar 20 '14 at 15:54
  • 1
    Hi Guys, 2 quick questions here:- Question 1: Suppose there are 2 WSP solutions deployed, both have packaged 'test.dll'. Then, will there be 2 dlls in GAC? Question 2: Suppose I retract 1 solution, then will the dll of other solution also get retracted? – variable Mar 13 '15 at 09:30
  • Good question and a major downside of using the WSP deployment approach. If you have different versions of test.dll, there will be two DLLs in the GAC. If you have the same version of test.dll the old version will be overwritten. If you retract your WSP, test.dll will be deleted even if still referenced from another WSP/solution. Different versioned DLL would be fine and not be deleted. – Dennis G Mar 13 '15 at 14:24