Wednesday, September 06, 2006

create sharepoint webpart(wss2) with vs2005

1. Create a class library;
2. Reference microsoft.sharepoint.dll;
3. Inherits the Microsoft.SharePoint.WebPartPages.WebPart;
4. compile->dll;
5. copy dll to sharepoint server root \bin or GAC;
6. add safecontrol to web.config of sharepoint server root;
7. browse ../_layouts/1033/newdwp.aspx to populate the webpart;

Note:
1. Enviroment: Windows Sharepoint service 2.0, sharepoint web server running on .net framework 2.0 (as for upgrade or downgrade to ver1.1, http://support.microsoft.com/kb/894903)

2. about "Name apears to be ..": check the web.config: trust level=..., set to "Full" for test.

3. About local machine debug, download windows work flow and vs2005 extension. can attach the instance to the workflow with w3wp.

4.about reference others dll, drag them into GAC for test usage.

5.Basiclly, it's hard to debug the custom web part(if it's developed by a class libraty instead of web controls). there are some simple tips for debugging the web part. if there is a win2003 server with VS 2005/2003 and sql server integrated, you are lucky. mostly,there is a virtual server for development and test use only. a small tip, compile your assembly into the virtual server directly, so you do not need copy/paste them every time which take your long time. another small thing, if you have try...catch...end try for exception handler(you would better have it !) , it's better to have a small label control added in the catch cluse, so you could get the exception message shown.

No comments: