我在“代码访问安全”遇到的问题,并得到了解决!

    应客户需求,写了个可以在List中分类查找的webpart(关于这个webpart的具体需求请参阅我的博客中 WSS3.0的搜索功能一文)。在编写代码的时候用到了Microsoft.sharepoint.webcontrols下的ListViewByQuery类,用visual studio 2005自动部署(我安装了微软提供的webpart for visual studio的扩展插件)webpart在本地调试的时候什么问题都没,但是把webpart部署到目标服务器上的时候却出现了问题。显示webpart不能被输出。于是我看了下日志,找到了提示的错误!

An SPRequest object was not disposed before the end of this thread.  To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it.  Due to flags specified at object creation, this will not be freed until processed by garbage collection.  Allocation Id: {717A4E83-47C3-4C25-A582-2D32B5AA90E2}  To determine where this object was allocated, create a registry key at HKEY_LOCAL_MACHINE"SOFTWARE"Microsoft"Shared Tools"Web Server Extensions"HeapSettings.  Then create a new DWORD named SPRequestStackTrace with the value 1 under this key.

Error importing WebPart. Assembly  ListSearch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, TypeName. ListSearch.ListSearch

我想来想去,问题应该出在这个类不允许被访问的问题上。于是我修改了sharepoint站点的信任级别。
打开SPS虚拟站点的根目录下的web.config文件,找到下面这行:
<trust level="WSS_Minimal" originUrl="" />
将其修改为:
<trust level="WSS_Medium" originUrl="" />

如果不像修改web.config文件,把webpart部署到GAC中也可以解决(visual studio自动部署的时候就是部署到GAC)

问题终于得到了解决,webpart正常输出。

转载于:https://www.cnblogs.com/li7125502/archive/2007/09/21/901298.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值