WebPart 基础
1.在项目中填加对Microsoft.SharePoint.dll的引用
a)如果你在Microsoft.SharePoint server上开发,可以在引用中直接找到。
b)如果没有,那就要将Microsoft.SharePoint.dll文件copy到你的目录中,加以引用。
2.添加System.Xml的引用。
3.指定Build output path。
a) 指定到Assembly所在目录。如:C:"inetpub"wwwroot"bin。
b) 想发布到GAC中(C:"windows"assembly),只能用copy 和 .net 命令gacUtil.exe注册。
c) 发布到其它目录中(for example, "inetpub"wwwroot"mydir or mydir2"bin),这样,你需要修改web.config文件,在<configuration>中加入下面的节点
<runtime>
<assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">
<probingprivatePath="mydir;mydir2"bin"/>
</assemblyBinding>
</runtime>
4.设置版本号
a) 打开文件AssemblyInfo.cs,修改成
[assembly: AssemblyVersion("1.0.0.0")] |
WebPart是在Internet or Intranet上开发设计的,为了在创建WebPart时的安全原因,你必须用强名来指定你的WebPart,这样用户才能准确的打到你提供的WebPart。
a) 生成一个强名文件。Sn.exe –k c:"keypair.snk
b) 填加强名引用
[assembly: AssemblyKeyFile("c:""keypair.snk")] |