Sharepoint Wsp部署

问题描述:



我已经开发了解决方案,也创建了WSP文件.通过使用Power Shell,我将Wsp部署在了共享点中.现在,我尝试使用C#以编程方式部署另一个Wsp,但出现了错误提示访问被拒绝".

这是我的代码,用于添加和部署解决方案.

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);



我调试了代码,发现异常发生在第一行.


谢谢,
Velkumar.



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


Thanks,
Velkumar.

您正在尝试运行代码场级别的代码.您使用的是具有服务器场级别权限的帐户吗?

您可能需要查看此 SPSecurity.RunWithElevatedPrivileges [ ^ ]

Solutions.Add返回一个SPSolution,因此不需要
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"];



您还应该使用 SPUtility.GetGenericSetupPath [ ^ ]而不是Server.MapPath



You should also be using SPUtility.GetGenericSetupPath[^] rather than Server.MapPath



我想在全球范围内部署它.对于管理中心,我们的默认端口是80和22222.我应该在哪里更改安全设置.全局部署解决方案的过程是什么.

另外,我使用服务器场级别帐户作为管理员,该帐户具有完全控制权限.
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.