| | |
This Month
December 2008
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Year Archive
Login
User name:
Password:
Remember me 
View Article  HOW TO Deploy assemblies to GAC for Sharepoint applications using WSPBuilder Extensions
Have't we had faced problems to automate deploying .net assemblies to GAC whilst developing sharepoint applications?, Thanks to keutmann for developing WSPBuilder Extensions. Here i have made an attempt to describe the same in few steps using WSPBuilder Extensions.

Very first thing is, this demo needs WSPBuilder Extensions add-in for Visual Studio. You can download the same here (opens new window).

After the installation of WSPBuilder Extensions, you would proably see the menu item available for a right click on project! as shown in fig below:



As a first Step, I will create a project by choosing WSPBuilder Project Template as shown in fig below:


Cilck OK and you would see the following project structure created by vs.net for you.


As seen in above fig, folder "12" is created where this folder represents Sharepoint 12 hive folder. Anything that would go to hive folder should be created under this folder where while deployment, all artifact will then go to Sharepoint 12 hive folder.

And another file created for you is solution.txt, which contains soultionid so that you can use this as id for your features.

For this demo, to deploy .net dlls to GAC, you would need to create a folder called GAC and copy all .dlls to this folder.
Next, for the demo purpose, I will create a class library under this same demo solution and copy the output .net dlls to the GAC folder as shown in fig below:



then I would xcopy MyBusinessObjectLibrary.dll to GAC folder on post build of this project. When build the solution, MyBusinessObjectLibrary.dll is copied to GAC. and right click on the project, choose Build WSP as shown in fig.



or Choose Create Deployment Folder item. This will create a folder called "Deploy" under Bin folder as shown in fig
below:



Last but not least, under deploy folder, create following setup of files or you can download here
1. setup.exe.config file with following contents
2. readme.html
3.eula.rtf.

The setup.exe.config should have following contents in it.




Now, its time to deploy. Double Click Setup.exe to test the deployment, which would then shows setup wizard as shown in fig below: and follow onscreen instructions. At the end of this process, you should be able to see your .net dlls deployed to GAC.


















Source Code: ArticleDeployDemoSolution.zip
View Article  How to elevate Permissions for using Sharepoint Object model
Many of the operations you perform with the object model—even a simple listing—will require administrative permissions. This is because SharePoint applies security restrictions to the use of the object model. However, there are many times when you would like to display information—such as a site listing—to a user that does not have administrator rights. In these cases, you must utilize the SPSecurity class to temporarily run object model code with elevated permissions. These elevated permissions allow you to run code under the identity of the application pool account.
          In order to run code with elevated permissions, you must encapsulate the code in a function that has no return value. You then create an instance of the CodeToRunElevated class using the name of the function as an argument. You can subsequently execute the code by calling the RunWithElevatedPrivileges method of the SPSecurity object and passing in the CodeToRunElevated object. Below shown is  an example that calls a method to list all of the available features in a farm.

<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"%>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.WebControls" %>
<asp:Content ID="Content4" runat="server"
ContentPlaceHolderID="PlaceHolderMain">
<%
SPSecurity.CodeToRunElevated myCode =
new SPSecurity.CodeToRunElevated(ShowFeatures);
SPSecurity.RunWithElevatedPrivileges(myCode);
%>
</asp:Content>
<script language="C#" runat="server">
protected void ShowFeatures()
{
//Code goes here
}
</script>
Welcome!

        I am Purushotam R. Tumkur, an IT Engineer by profession since the late 90's.  During that time I have spent a great amount of time working as a Software Programmer/Analyst/Consultant specializing in Microsoft Techonlogies such as Microsoft.Net Framework, BizTalk, Sharepoint and Sql Server.  Read more..

Download Latest Resume:!Updated
Updated on: 08-May-09


My favourites (opens new window)