SharePoint 中的信息管理策略

发布于 2024-07-04 10:30:48 字数 620 浏览 10 评论 0原文

这是一个晦涩难懂的难题,但它让我彻底发疯:

我正在 MOSS 中创建自定义信息管理策略。 我已经实现了 IPolicyFeature,并且我的策略功能很高兴通过配置新的 SPItemEventReceiver 来注册自身。 我的图书馆中的所有新项目都会按其应有的方式触发事件,并且一切正常。

IPolicyFeature 还有一个 ProcessListItem 方法,该方法应该追溯地将策略应用于库中已有的项目(至少,只要它不断返回 true 就应该这样做)。 但事实并非如此。 它仅将该策略应用于库中的第一个项目,我完全不知道为什么。

它似乎没有抛出异常,并且它确实从处理第一项返回 true,我想不出还有什么可看的。 任何人?

编辑:下面科里的回答让我走上了正确的道路。 其他东西确实失败了——我不知道是什么,因为我的 Windbg-fu 不是它应该的样子,但我怀疑它类似于“在迭代时修改集合”。 我的代码修改了传递给 ProcessListItem 的 SPListItem,然后对其调用 SystemUpdate; 一旦我更改了代码,以便它创建了自己的变量(指向完全相同的 SPListItem)并使用它,问题就消失了......

An obscure puzzle, but it's driving me absolutely nuts:

I'm creating a custom Information Management Policy in MOSS. I've implemented IPolicyFeature, and my policy feature happily registers itself by configuring a new SPItemEventReceiver. All new items in my library fire the events as they should, and it all works fine.

IPolicyFeature also has a method ProcessListItem, which is supposed to retroactively apply the policy to items that were already in the library (at least, it's supposed to do that for as long as it keeps returning true). Except it doesn't. It only applies the policy to the first item in the library, and I have absolutely no idea why.

It doesn't seem to be throwing an exception, and it really does return true from processing that first item, and I can't think what else to look at. Anyone?

Edit: Cory's answer, below, set me on the right track. Something else was indeed failing -- I didn't find out what, since my windbg-fu isn't what it should be, but I suspect it was something like "modifying a collection while it's being iterated over". My code was modifying the SPListItem that's passed into ProcessListItem, and then calling SystemUpdate on it; as soon as I changed the code so that it created its own variable (pointing at the exact same SPListItem) and used that, the problem went away...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

此生挚爱伱 2024-07-11 10:30:48

我能想到的只有几件事可以尝试。 首先,您是否在可以使用 Visual Studio 进行调试的机器上进行开发? 所以只要逐步完成它即可。

假设情况并非如此 - 我要做的是在注册策略之前启动 WinDBG 并将其附加到进程。 打开第一次机会异常,以便在异常发生时它会中断。 您可以通过在破解后发出命令“sxe clr”来完成此操作。以下是有关 WinDBG 的更多信息:

http://blogs.msdn。 com/tess/archive/2008/06/05/setting-net-breakpoints-in-windbg-for-applications-that-c​​rash-on-startup.aspx

我要做的就是观察第一次机会抛出异常,并执行 !PrintException 来查看发生了什么。 我的猜测是,某个地方抛出了异常,导致应用程序停止处理其他项目。

ProcessListItem 的逻辑是什么样的? 您是否尝试过仅返回 true 以确保其有效?

There's only a couple of things I can think of to try. First, are you developing on the box where you might be able to use Visual Studio to debug? So just stepping through it.

Assuming that's not the case - what I'd do is fire up WinDBG and attach it to the process just before I registered the policy. Turn on first chance exceptions so that it breaks whenever they occur. you can do that by issuing the command "sxe clr" once it is broken in. Here's a little more info about WinDBG:

http://blogs.msdn.com/tess/archive/2008/06/05/setting-net-breakpoints-in-windbg-for-applications-that-crash-on-startup.aspx

What I'd do is then watch for First Chance exceptions to be thrown, and do a !PrintException to see what is going on. My guess is that there is an exception being thrown somewhere that is causing the app to stop processing the other items.

What does the logic look like for your ProcessListItem? Have you tried just doing a return true to make sure it works?

当爱已成负担 2024-07-11 10:30:48

有一些不错的想法,谢谢。 Visual Studio 调试器没有显示异常(并且我已将所有内容包装在 try/catch 块中以防万一),但我没有想过尝试 Windbg...

Some nice ideas there, thanks. The Visual Studio debugger wasn't showing an exception (and I've wrapped everything in try/catch blocks just in case), but I hadn't thought of trying Windbg...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文