Friday, January 02, 2009

Developing Sharepoint Application By Using Visual Studio 2008


To Develop Sharepoint Application by using Visual Studio, we need to have Sharepoint Extensions for Visual Studio. It can be isntalled from

http://www.microsoft.com/downloads/details.aspx?familyid=7BF65B28-06E2-4E87-9BAD-086E32185E68&displaylang=en


This installer is supported only for 32 bit OS. It is not supported for 64 bit OS.

For the development of the sharepoint application, I have used Visual Studio 2008 Team Suite, Sharepoint Server 2007 and Windows Server 2008.

Open Visual Studio, Select File -> New -> Project.

In the dialog, Select Sharepoint -> Team Site Definition, and enter the name, location and click Ok.




Once the solution is created, add a new item.




and Select Visual C# -> Sharepoint -> List Definition and click Ok.





This will show the following dialog.





Select Custom List and check Create an Instance of this List. If you want to add an event handler, you can check Add with Event Receiver. Once you click Ok, it will show the following in the solution explorer.





Open instance.xml, and add OnQuickLaunch="TRUE" Description="Krishna List Instance" as shown in the following.





If you want, you can add VersionEnabled and EnableMinorVersions as attributes of List tag in schema.xml.

To deploy the application, Press F5. It will create wsp file and deploy the application. If you are using windows 2008 server, it may give the error Access Denied while deploying the application.

To deploy the application, run the following commands from the command prompt. In windows 2008 server, the command prompt should be run as Administrator.

stsadm -o addsolution -filename TeamSiteDefinition4.wsp


stsadm -o deploysolution -name TeamSiteDefinition4.wsp -url http://krishna-2k8/sites/abcd -local -allowGacDeployment


You can find stsadm.exe in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN

While creating the sharepoint instance, if you have not selected, Add with Event Receiver, then you would receive the following error message.

This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application.


You will get the above error, if you do not have any C# code to be deployed. In that case, run the following command.

stsadm -o deploysolution -name TeamSiteDefinition4.wsp -local -allowGacDeployment


Now, open the browser, and go to the website that you have given in deploysolution. In the above command, I have given http://krishna-2k8/sites/abcd

Go to Site Actions -> Create. It will open Create page of sharepoint. In that select, Web pages -> Sites and Workspaces.





Enter title, description and URL name.

Select a template -> Development contains the solutions that we deployed. Select that template and click ok. It will create the sharepoint application from our template.

To delete the solution, run the following commands

If you have selected Add with Event Receiver while creating the list instance (or if you have any C# code)
stsadm -o retractsolution -name TeamSiteDefinition4.wsp -local -url http://krishna-2k8

Otherwise
stsadm -o retractsolution -name TeamSiteDefinition4.wsp -local


and then run the following command.

stsadm -o deletesolution -name TeamSiteDefinition4.wsp

2 comments:

  1. I am creating an email template on a sharepoint platform where I can receive important details from my Value added resellers. Can you send me an email with necessary information

    ReplyDelete
  2. I am very interested in your article about sharepoint and it is very helpful and useful for me. Thanks for share this.

    ReplyDelete