Monday, September 29, 2008

MOSS deploy dll in bin folder

This article i hope will help many starters as well as experienced SharePoint developers to understand the way SharePoint uses the dll deployed in its site directory bin folder which is located under the inetpub/virtual directory folder. As we all know and have used mostly (atleast in our case) deployment of dll (Custom WebPart, Custom control etc) in GAC (Global Assembly Cache) was the way to develop SharePoint solutions. But there is another very good approach which is mentioned below in steps. That is to deploy the dll directly to the site bin folder. Here are the steps to accomplish:

1. Set Output path of the projects (Project in which you are keeping webpart control classes) to the site bin folder. You can find the path by navigating to C:\Inetpub\wwwroot\virtual directory\port number\bin

2. Build the solution and make sure it is compiling successfully.
3. Add a safe control entry to the web config file. Do not mention public key token. Do not strong name the project.
4. That's it, your code is deployed in the site's bin directory and its information is located in the config file. Go Ahead and populate the web part gallery with the web part and add it  to a page.

Advantages:
1. Biggest advantage is the fact  that you do not have to reset iis after every compilation of code.
2. You can directly copy the dll from the other bin folders to this as and when required.

DisAdvantage
1. As you are deploying code to the bin folder of particular site, it will not be available globally. That means you will need to add the dll to every site's bin folder.

I hope this article will clear most of your doubts. In case something is not understood, do write a comment to this post or email us at sharepointkings@gmail.com

6 comments:

Anonymous said...

Useful stuff thank you! I wanted to avoid GAC'ing if I could.

elizas said...

In SharePoint, one can use PageViewer WebPart within a webpart page to display another web page within it. All that one is required to do is, provide the URL of the page as the ContentLinkparameter of the WebPart.

http://www.mindfiresolutions.com/lp/sharepoint-development.htm

Chee Pin said...

very useful tips...
with the way we can prevent IIS reset and messy ddl in GAC.

JC said...

I've deployed like this before. We have two Web Front ends so we have to deploy to both servers. One thing I was wondering about was DLL's we reference in our solutions. Would presume we need to deploy those too, but will our custom solutions know where to find them.. and does this get complicated if multiple web front ends? About to test this.

JC said...

We've deployed like before. We have two Web Front ends so it's times 2. But now wondering what happens when your solution has DLLs it refrences, would imagine we have to deploy those too, but does the solution need to reference it locally? And how will that work when mulitple front ends. About to find out I guess - I suspect okay to refence on my client during dev and compile and then it's just needs to be avialble to the site under it's bin and safe in the web.config... well at least I'm hoping so.

SharePoint Kings said...

while executing your solution, as far as reference found then it will not be any problem. reference may be from gac or bin will not make any difference for code (unless proper privilege issue).

just make sure your configuration step by step like first DLL, then web.config entries and at last the code which refers your DLL.

hopefully it should work this is what we hope also.

share your result as well with us.




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com