2

I have a need to get collection of SPLitsItem currently viewed to user. My solution is a ribbon button which calls custom application page in LAYOUTS via javascript in custom action. Application page gets current view id and current folder url via query string. I am using next code to get list items:

/// <summary>
/// Gets items from folder.
/// </summary>
/// <param name="folder">
/// Folder containing items 
/// </param>
/// <returns>
/// Items by <see cref="_viewId"/>. 
/// </returns>
private SPListItemCollection GetItems(SPFolder folder)
{
    var library = folder.DocumentLibrary;
    if (library == null)
    {
        return null;
    }

    var view = library.GetView(_viewId);
    // this also throws exception
    //var query = new SPQuery { Query = view.Query, Folder = folder };
    //var items = library.GetItems(query);

    var items = library.GetItemsInFolder(view, folder);

    return items;
}

Everything is fine on my single-server dev machine, however on our test environment (two WFE's and one database server) I've got COM exception: Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION)). Here are logs:

Entering monitored scope (Request (GET:https://extra.fondiatools.net:443/boardnet/_layouts/DLZ/Download.aspx?mode=folder&viewId=%7BC776D164%2D0A11%2D4702%2DB246%2D44FC65D69B2A%7D&folder=%2Fboardnet%2FHallituksen%20kokoukset%20ja%20tapahtumat%2FEmpty%20docset))     
Name=Request (GET:https://extra.fondiatools.net:443/boardnet/_layouts/DLZ/Download.aspx?mode=folder&viewId=%7BC776D164%2D0A11%2D4702%2DB246%2D44FC65D69B2A%7D&folder=%2Fboardnet%2FHallituksen%20kokoukset%20ja%20tapahtumat%2FEmpty%20docset)  5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Site=/boardnet  5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaving Monitored Scope (GetFileAndMetaInfo). Execution Time=17,8967    5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaving Monitored Scope (GetWebPartPageContent). Execution Time=18,0222 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
WcfSendRequest: RemoteAddress: 'http://wfe1:32843/2a0bc8eace494e86b2ba0b784fe2ebb6/ProfilePropertyService.svc' Channel: 'Microsoft.Office.Server.UserProfiles.IProfilePropertyService' Action: 'http://Microsoft.Office.Server.UserProfiles/GetProfileProperties' MessageId: 'urn:uuid:f139dfba-7c6f-4370-835f-26800c2955ab'     
An unhandled exception occured. Watson will be invoked. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Watson bucket parameters: Microsoft SharePoint Foundation 4, ULSException14, 269cd32d "sharepoint foundation", 0e00178d "14.0.6029.0", d2cb6259 "onetutil.dll", 0e0017e5 "14.0.6117.0", 4f4f0996 "thu mar 01 07:31:02 2012", MISSING, 0009fc83 "0009fc83", c0000005 "c0000005", 3833376c "837l" 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Unknown SPRequest error occurred. More information: 0x80020009  5458ddda-6c27-4711-b1fb-ed2b6df34a4a
System.Runtime.InteropServices.COMException: Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))    at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView)     at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, IS... 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
...P2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView)   5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741848, name (unknown), and thread local refcount 12. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true.    5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741908, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A7419C8, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000FB9B730, name C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\DocumentLibrary\doclib-1033, and thread local refcount 11. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true.    5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A8070C8, name (unknown), and thread local refcount 2. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A807008, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741F08, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741D88, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741C08, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741E48, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741788, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A7416C8, name (unknown), and thread local refcount 28. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true.    5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 0000000013A11800, name u-Docs-4294967295-1033, and thread local refcount 11. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true.   5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 000000000A741CC8, name (unknown), and thread local refcount 1. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true. 5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaked record detected with address 0000000013A13940, name pl-47951A13515342F28C1FB5049CCCC54C-B6ED949E86E648C7B5EFFA83ECF86939-37-0-1033, and thread local refcount 6. To see AddRef/Release callstacks for this leak, run stsadm -o setproperty -pn refcountcallstacktrackingenabled -pv true.    5458ddda-6c27-4711-b1fb-ed2b6df34a4a
Leaving Monitored Scope (Request (GET:https://extra.fondiatools.net:443/boardnet/_layouts/DLZ/Download.aspx?mode=folder&viewId=%7BC776D164%2D0A11%2D4702%2DB246%2D44FC65D69B2A%7D&folder=%2Fboardnet%2FHallituksen%20kokoukset%20ja%20tapahtumat%2FEmpty%20docset)). Execution Time=190,6242    5458ddda-6c27-4711-b1fb-ed2b6df34a4a

I checked view on test environment and noticed that this error appears only when GroupBy is used in corresponding Caml query. This is it:

<View Name="{01CA0D2A-9858-4EDA-9B5E-F2A612B5DC3C}" MobileView="TRUE" Type="HTML" DisplayName="Kokousmateriaali" Url="/boardnet/Hallituksen kokoukset ja tapahtumat/Forms/Kokousmateriaali.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/dlicon.png">
    <Query>
        <GroupBy Collapse="FALSE" GroupLimit="30">
            <FieldRef Name="Esityslistan_x0020_kohta"/>
        </GroupBy>
        <OrderBy>
            <FieldRef Name="FileLeafRef"/>
        </OrderBy>
    </Query>
    <ViewFields>
        <FieldRef Name="DocIcon"/>
        <FieldRef Name="LinkFilenameNoMenu"/>
        <FieldRef Name="Modified"/>
        <FieldRef Name="Editor"/>
    </ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Aggregations Value="Off"/>
    <Toolbar Type="Standard"/>
</View>

I've created same view on my machine and didn't get any errors. Also I tried to remove GroupBy entries from query and it works fine.

Here on sharepoint.stackexchange.com I found related question SPSiteDataQuery throwing exception while setting it's Query property I tried to add fields used in GroupBy and OrderBy to ViewFields but it doesn't help.

I'm very unhappy with this error - I don't know how to fix it and Google didn't help me. However the same logic is used on client side via javascript client object model and it works fine.

My first conclusion is that our test environment has some problems. Could you give me any advice how to fix it or do my task alternatively?

2 Answers 2

1

It seems that your crash is happening immediately after this line. Can you ensure that User Profile Service is properly functioning (check Services on Server and make sure both User Profile and User Profile Synchronization services are on Started)

WcfSendRequest: RemoteAddress: 'http://wfe1:32843/2a0bc8eace494e86b2ba0b784fe2ebb6/ProfilePropertyService.svc' Channel: 'Microsoft.Office.Server.UserProfiles.IProfilePropertyService' Action: 'http://Microsoft.Office.Server.UserProfiles/GetProfileProperties' MessageId: 'urn:uuid:f139dfba-7c6f-4370-835f-26800c2955ab'     

The error code 0x80020009 also suggest an UAC related problem, therefore make sure you check permissions of Service Accounts. If you develop something make sure you check here http://ruudheemskerk.net/archive/2009/06/11/famous-exception-occurred.-exception-from-hresult-0x80020009-disp_e_exception.aspx about improperly dispose Context Object (e.g. SPContext.Current.XXX)

Hope it helps, C:\Marius

1
  • We don't use UPSS at all, and also I did a series of test and this string is not appeared in logs anymore. As for correct disposing - I don't dispose any member of current SPContext. Commented May 8, 2012 at 15:14
1

I've just had a similar issue:

Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)

The symptoms were similar to above with the issue only happening in test and prod with front and back end servers. The entire page that my web part was on would not display. Eventually I located that the issue only occurred when there were more items returned by the query than the row limit.

Solution: Remove row limit from the query. Return all results and restrict the number of items in code. DO NOT USE the RowLimit property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.