SharePoint 中的 HRESULT 异常:0x80020009 (DISP_E_EXCEPTION)) [英] Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION)) in SharePoint

查看:66
本文介绍了SharePoint 中的 HRESULT 异常:0x80020009 (DISP_E_EXCEPTION))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在谷歌搜索了很多小时以解决上述 Sharepoint 异常之后,我来到 SO 寻求帮助...

After googling for many hours for a solution for the above Sharepoint exception, I have come to SO for help on this one...

我相信我得到上述异常的原因是因为以下代码:

I believe the cause of me getting the above exception is because of the following code:

try
{
    using (SPSite site = new SPSite(siteId, spUserToken))
    {
        using (SPWeb web = site.OpenWeb(webId))
        {
            createNewSite(web);
        }
    }
}

createNewSite(web) 使用 AllowUnsafeUpdates 更改web"的名称和 URL,因此当它退出方法时,它已被更改.我几个月的 Sharepoint 开发经验表明,这就是异常的原因.不再使用web",因此我可以轻松地将其置空.这里的问题是......它没有用:

createNewSite(web) changes the name and URL of "web" using AllowUnsafeUpdates, so when it comes out of the method it has been changed. My few months worth of Sharepoint developing experience suggest that that is the cause of the exception. "web" is no longer used anymore so I can comfortably null it myself. The problem here is... it didnt work:

try
{
    using (SPSite site = new SPSite(siteId, spUserToken))
    {
        SPWeb web = null;
        using (web = site.OpenWeb(webId))
        {
            createNewSite(web);
            if (web != null)
            {
                web = null;
            }
        }
    }
}

我相信原开发者使用 using 声明是为了避免 SPWeb 对象泄漏.除此之外,我认为我可以仅仅为了摆脱那个可怕的异常而打破这种模式.

I believe that the original developer used the using declaration to avoid SPWeb objects from leaking. Asides that I think it is okay for me to break this pattern solely for the purpose of getting rid of that dreaded exception.

那么问题是:我可以对上面的代码做些什么来潜在地修复这个异常?

So the question: what can I do to the above code to potentially fix this exception?

谢谢.

推荐答案

使用名为 createNewSite 的方法来更改现有站点是一个不好的迹象 - 您也应该为此发布代码.

Having a method called createNewSite that changes an existing site is a bad sign - you should post the code for that also.

然而,没有必要将 web 设置为 null - 它没有任何影响,因为它无论如何都会超出范围.

There is however no need to set web to null - it doesn't have any effect as it is about to go out of scope anyway.

更可能的原因是您调用的自定义方法有问题或所用 ID 的有效性存在问题.

A more likely cause is something wrong in the custom method you are calling or an issue with the validity of the ids used.

这篇关于SharePoint 中的 HRESULT 异常:0x80020009 (DISP_E_EXCEPTION))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆