输入字符串格式不正确SPSite

时间:2011-09-09 05:15:29

标签: c# sharepoint wss-2.0

我正在使用带有sharepoint portal server 2003的WSS 2.0。 我正在vs 2008中创建Web应用程序,它打开了在门户网站服务器中创建的sharepoint站点。

当我将网站地址传递给SPSite时,它给了我错误。 “输入字符串格式不正确”

这是我的代码

string site_Str= "http://<serverName>:<PortNumber>/sites/<TopLevelSite>";
SPSite site=new SPSite(site_Str); // here it gives error

这里是堆栈跟踪

"   at Microsoft.SharePoint.i.a(Boolean A_0, String A_1, Guid A_2, Int32& A_3)\r\n   at Microsoft.SharePoint.SPSite.j()\r\n   at Microsoft.SharePoint.SPSite.a(String A_0, SPVirtualServer A_1, a A_2, Int32 A_3)\r\n   at Microsoft.SharePoint.SPSite..ctor(String strUrl)\r\n   at testRoundLink._Default.GetJavaScript() in E:\\resarch\\testRoundLink\\testRoundLink\\Default.aspx.cs:line 46\r\n   at testRoundLink._Default.Page_Load(Object sender, EventArgs e) in E:\\resarch\\testRoundLink\\testRoundLink\\Default.aspx.cs:line 19\r\n   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)\r\n   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)\r\n   at System.Web.UI.Control.OnLoad(EventArgs e)\r\n   at System.Web.UI.Control.LoadRecursive()\r\n   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)"

我该如何解决这个问题。

提前致谢

1 个答案:

答案 0 :(得分:0)

试试这个:

string site_Str= "http://<serverName>:<PortNumber>";
SPSite site=new SPSite(site_Str);