Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

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.


Thanks,
Velkumar.
Posted
Updated 29-Dec-11 18:36pm
v2

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
 
Share this answer
 
v2
Hi,
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.
 
Share this answer
 
v2
Comments
[no name] 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900