Click here to Skip to main content
11,706,979 members (55,487 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Sharepoint Access Deployment , +

I have developed solution also I created a WSP file. By using power shell i deployed the Wsp in the sharepoint. Now i trying to programatically deploy another Wsp using C# and I got an Erroe "Access Denied".

This is My Code to add and deploy the solution.

SPFarm.Local.Solutions.Add((Server.MapPath("~/_layouts") + "/DemoWSP10.wsp"));
                SPSolution customSolution =  SPFarm.Local.Solutions["DemoWSP10.wsp"];
                customSolution.Deploy(DateTime.Now, false, true);

I debug the code,I find that the exception occured in the first line.

Posted 29-Dec-11 18:34pm
Edited 29-Dec-11 18:36pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You are trying to run code farm level code. Are you using an account that has farm level permissions?

You may need to look at this SPSecurity.RunWithElevatedPrivileges[^]

Solutions.Add returns an SPSolution, so there is no need for
SPSolution customSolution =  SPFarm.Local.Solutions["DemoWSP10.wsp"];

You should also be using SPUtility.GetGenericSetupPath[^] rather than Server.MapPath
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I want to deploy it globally. Our default port is 80 and 22222 for Central Administration. Where should I need to change the security settings. What is the procedure for globally deploy the solution.

Also I am using the farm level account as Administrator, which has full control permission.
Mark Nischalke at 31-Dec-11 0:06am
First, you add a question or comment, not a new solution

Unless it is a farm solution meant to used in central admin you should not deploy it there. A farm solution is deployed globally, thats the meaning of farm solution. I believe you need to do some research on SharePoint solutions and deployment before attempting to work with them or sharepoint.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 165
1 OriginalGriff 125
2 chainerlt 110
3 ppolymorphe 89
4 Mika Wendelius 70
0 OriginalGriff 9,178
1 Sergey Alexandrovich Kryukov 8,512
2 CPallini 5,189
3 Maciej Los 4,766
4 Mika Wendelius 3,696

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 31 Dec 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100