讨论:为什么网络不能工作?控制台可以吗?-为什么文档库不能工作?通用列表可以吗?Update 2006-9-8,·这个事Beta2的一个Bug 在B2TR中修复了 B2TR的下载马上会公布,·
终极管理员 知识笔记 77阅读
-。 You said that in the code, on the surface, he didn't have any problems, and there was a problem as soon as he ran. Is this depressing? I wonder if other friends have seen it? In Moss 2007, add a document library with SPList. Adding will cause strange problems. The details are as follows:一、为什么Web不行?Console可以?1)Web下established a web project in the visualization studio, with the following interface: the code is as follows: PublicPartialclass _ Default: system. Network. ui。 Page {protectedVoidpage _ load (object sender, event target) {//Solve the problem of security verification SPGlobalAdminglobalAdmin 1)'=newsglobalbaladmin (); Context. Items[SPGlobalAdmin。 requestfromadimport]=true; Page. RegisterHiddenField(_ _ request digest),globalAdmin。 AdminFormDigest); } protectedvoidbutton 1 _ Click(object sender,EventArgse){ spsitemsite=news site('); //Allow unsafe updates
a(0, 0, 0, 1)"> mysite.AllowUnsafeUpdates = true;mysite.RootWeb.AllowUnsafeUpdates = true;
//添加Demo文档库
mysite.RootWeb.Lists.Add("Demo", "Demo", SPListTemplateType.DocumentLibrary);
this.Label1.Text = mysite.RootWeb.Lists["Demo"].ID.ToString();
}
}
运行出现问题如下:
但是,虽然出错,Demo文档库其实已经创建出来:
2)Console下

mysite.AllowUnsafeUpdates = true;
mysite.RootWeb.AllowUnsafeUpdates = true;
mysite.RootWeb.Lists.Add("Demo", "Demo", SPListTemplateType.DocumentLibrary);
Console.WriteLine("The Created Document Library's Guid :"+mysite.RootWeb.Lists["Demo"].ID.ToString());
代码功能和Web下一样,运行成功!
为什么Web不行?Console可以?
二、为什么Document Library不行?Custom List可以?
改变以上Web工程中的一句代码,改成添加自定义列表

运行成功:
在SharePoint站点中出现创建的列表
为什么Document Library不行?Generic List就可以?
三、讨论
1)这个是不是WSS V3 Beta的一个Bug?我也不知道
2)Web下和Console下都用的应该是管理员权限,Web用了localhost访问,所以应该不是权限的问题;
2)从出错的地方看,可能是Feature或者WorkFlow的问题,但是Document Library和Generic List是同属于一个基类,问题的可能就是处在Generic List和Document Library不同的地方,所以这个问题的解决可以从Document Library 和Generic List两种ListTemplate的不同上来找。
问题的出处会继续寻找,得到了答案会更新post。
大家有什么答案的话请不吝赐教!
现在阶段,利用代码添加文档库的办法,我是这么干:
{
mysite.RootWeb.Lists.Add("Demo", "Demo", SPListTemplateType.DocumentLibrary);
}
catch
{}
加上Try-Catch,因为其实文档库已经存在了。