共享点错误 [英] Sharepoint errors
问题描述
我已经创建了一个.net Web部件并将其部署在共享点站点上.预览时,共享点将引发错误,提示预览Web部件时发生错误"
I have created a .net web part and deployed it on the sharepoint site. When I preview it, the sharepoint throws up an error saying "An error occured when previewing the Web Part"
Web部件中的代码如下
The code in the web part is as follows
Dim myweb As Microsoft.SharePoint.SPWeb = Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(Context)
'Dim mylist As Microsoft.SharePoint.SPList = myweb.Lists(System.Configuration.ConfigurationSettings.AppSettings("BedList").ToString())
Dim mylist As Microsoft.SharePoint.SPList = myweb.Lists("{80F6F320-E1F5-42EB-A2FB-895EAE00F589}")
Dim items As Microsoft.SharePoint.SPListItemCollection = mylist.Items
For Each item As Microsoft.SharePoint.SPListItem In items
returnString = returnString + "<br/>" + item("Status").ToString() + " For " + item("Title").ToString + "<br/>"
Next
有人知道为什么这行不通吗?我无法掌握所引发的执行力. 任何帮助都是很好的
Does anyone know why this would not work. I can not get hold of the execption thrown. any help would be greatful
推荐答案
首先,您应该通过更改web.config中的以下内容来使您的异常可见
First you should make your exceptions visible by changing the following in the web.config
CallStack = true
CallStack = true
<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
CustomErrors = Off
CustomErrors = Off
<customErrors mode="Off" />
然后您将看到真正的异常
Then you will see the real exception
您还可以尝试使用以下代码获取当前网站:
You can also try obtain the current web using the following code:
Dim myweb As Microsoft.SharePoint.SPWeb = SPContext.Current.Web
尝试获取列表时,其他问题可能与listId或ListName错误有关.
Other problem could be related with wrong listId ou ListName when you try to obtain the list.
希望有帮助
这篇关于共享点错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!