代码改变世界

使用stsadm命令部署和激活webpart解决方案

2009-12-25 13:40  Virus-BeautyCode  阅读(922)  评论(0编辑  收藏  举报

Solution.WebPart.webpart

 

<?xml version="1.0" encoding="utf-8"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <!--
      The following Guid is used as a reference to the web part class,
      and it will be automatically replaced with actual type name at deployment time.
      -->
      <type name="Solution.WebPart.SolutionWebPart, Solution.WebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"  />
      <importErrorMessage>Cannot import SolutionWebPart Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">SolutionWebPart Web Part</property>
        <property name="Description" type="string">SolutionWebPart Description</property>
      </properties>
    </data>
  </webPart>
</webParts>

 

Solution.WebPart.xml

 

<?xml version="1.0" encoding="utf-8"?>
<Elements Id="15f37071-ebef-46d0-984d-59fbe920a462" xmlns="http://schemas.microsoft.com/sharepoint/" >
  <Module Name="WebParts" List="113" Url="_catalogs/wp">
    <File Path="solution.webpart\Solution.WebPart.webpart" Url="Solution.WebPart.webpart" Type="GhostableInLibrary" />
  </Module>
</Elements>

 

feature.xml

 

<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Id="F4952FEB-52E3-4d1e-909A-F5297F2FB146"
          Title="Solution.WebPart"  Scope="Site" Version="1.0.0.0" Hidden="false"
          DefaultResourceFile="core">
  <ElementManifests>
    <ElementManifest Location="Solution.WebPart\Solution.WebPart.xml"/>
    <ElementFile Location="Solution.WebPart\Solution.WebPart.webpart"/>
  </ElementManifests>
</Feature>

 

1、首先在系统的环境变量中设置stsadm的运行路径,也就是【c:\program files\common files\microsoft shared\web server extensions\12\bin】。

stsadm1

2、然后,将下列命令行拷贝到setup.bat文件中

3、运行这个setup.bat文件

 

 

stsadm –o deactivatefeature –filename “solution.webpart\feature.xml” –url http://moss.virus.com/

stsadm –o retractsolution –name solution.webpart.wsp –immediate –allcontenturls

stsadm –o execadmsvcjobs

stsadm –o deletesolution –name solution.webpart.wsp

stsadm –o addsolution –filename solution.webpart.wsp

stsadm –o deploysoluiton –name solution.webpart.wsp –allcontenturls –immediate –allowgacdeployment –allowcaspolicies

stsadm –o execadmsvcjobs

stsadm –o activatefeature –filename “solution.webpart\feature.xml” –url http://moss.virus.com/

 

 

Sharepoint:The security validation for this page is invalid. Click Back in your Web browser

Sometimes while trying to delete documents or move documents from one library to another we get an error "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again” while trying to move documents from one document library to another document library."
This error is caused due to security validation. So there should be a way out to turn it off. One method to turn off security is:
Central Administration—>application management—->web application general settings–>turn security validation off
But, if we always keep it on there might be danger of malicious code.
So, we should handle this through coding, turn off security validation for our code to execute and then again turn it on.
SPWeb ospWeb = SPContext.Current.Web;
Microsoft.SharePoint.Administration.SPWebApplication webApp = ospWeb.Site.WebApplication;
webApp.FormDigestSettings.Enabled = false;
// our code should be inserted here
webApp.FormDigestSettings.Enabled = true;
For more details, visit http://techolyvia.wordpress.com/2008/10/24/the-security-validation-for-this-page-is-invalid-click-back-in-your-web-browser-refresh-the-page-and-try-your-operation-again/

 

 

页面安全验证失效,有时候是因为切换账户导致,估计是切换账户之后,前面的页面是另外一个权限的账户打开的,所以你退回去的话,可能安全验证就失效了。

 

下面是通过代码添加程序集到GAC中。gacutil.exe是安装框架之后会有的程序,如果没有也可以上网下载。

 

gacutil –uf wikieventhandler

gacutil –if wikieventhandler.dll

iisreset

 

pause