You are viewing limited content. For full access, please sign in.

Question

Question

The specified operation is not recognized

SDK
asked on December 2, 2015 Show version history

I'm getting an error, The specified operation is not recognized. [9051], when I call 

AnotherFolder = FolderListName.GetRowData(i);

in the following code block. It always fails when the count is 802. Usually when I get an error like this with SDK, it turns out I'm forgetting to call Dispose on an object. However, EntryListingRow doesn't have that. 

I've tried it on two different machines, two different repositories, and a set of folders named Folder X to make sure none of them are the issue.

I'm using Visual Studio 10, the 9.2 SDK, and Windows 2008 R2. Anyone have any ideas as to what I'm doing wrong?

FolderInfo FI = Folder.GetFolderInfo(@"\Case Management\CLIENT RECORDS\A", LfSesh);
EntryListingSettings ELSets = new EntryListingSettings();
ELSets.EntryFilter = EntryTypeFilter.Folders;
ELSets.AddColumn(SystemColumn.DisplayName);
ELSets.AddColumn(SystemColumn.Path);
FolderListing FolderList = FI.OpenFolderListing(ELSets);
EntryListingRow AFolder;
for (int i = 1; i <= FolderList.RowsCount; i++)
{
    AFolder = FolderList.GetRowData(i);
    string FolderPath = AFolder.GetDatumAsString(SystemColumn.Path) + @"\" + AFolder.GetDatumAsString(SystemColumn.DisplayName) + @"\";
    FolderInfo FI2 = Folder.GetFolderInfo(FolderPath, LfSesh);
    EntryListingSettings ELSetsName = new EntryListingSettings();
    ELSetsName.EntryFilter = EntryTypeFilter.Folders;
    ELSetsName.AddColumn(SystemColumn.DisplayName);
    ELSetsName.AddColumn(SystemColumn.Path);
    FolderListing FolderListName = FI2.OpenFolderListing(ELSetsName);
    FI2.Dispose();
}
FI.Dispose();
0 0

Answer

SELECTED ANSWER
replied on December 2, 2015

What is the point of the FolderListName FolderListing object on line 17? It is just opening a listing that doesn't get used (and not being Dispose()'d)

0 0

Replies

replied on December 3, 2015

FolderListing inherits from IDisposable, so it has a Dispose() method. A better way to handle this cleanup is with a using block:

using (FolderListing listing = folder.OpenFolderListing(elparams))
{
    foreach (EntryListingRow r in listing)
    {
        // do something with the row
    }

    // No need to Dispose(), the using block takes care of it
}

 

1 0
replied on December 2, 2015

It doesn't do anything in this version of the code. However, I'm glad I included it. It turns out that FolderListNames don't have Dispose that I can see, but do have Close. I put that in the loop, and now it's working. I'll start looking for Close as well as Dispose. Thank you very much for the help. I really appreciate it.

0 0
replied on December 3, 2015

Thanks for the good advice. It does raise a couple of questions though.

When I use a FolderListing object, no Dispose() method is listed, and when I call it anyway, I get this error.

'Laserfiche.RepositoryAccess.FolderListing' does not contain a definition for 'Dispose' and no extension method 'Dispose' accepting a first argument of type 'Laserfiche.RepositoryAccess.FolderListing' could be found (are you missing a using directive or an assembly reference?)

When I look up FolderListing in the SDK 9.2 .NET help file, I don't see IDisposable listed in its inheritance hierarchy. 

Can I only access FolderListing's Dispose() method through the Using directive? How do I tell if an Object in the .NET SDK inherits iDisposable?

0 0
replied on December 4, 2015

Looks like this is a bug in RepositoryAccess, the FolderListing class should expose IDisposable publicly. I filed a bug report to get this fixed.

0 0
replied on December 3, 2015

I'm getting much farther now after switching to the using statement, through about 51,000 folders. However, it still eventually fails with the same error. Do you have any other advice?

0 0
replied on December 4, 2015

Are you crawling folders using recursion? e.g. something like this:

void ProcessFolder(FolderInfo folder)
{
    using (FolderListing listing = folder.OpenFolderListing(settings))
    {
        foreach (EntryListingRow row in listing)
        {
            if ((EntryType)row[SystemColumn.EntryType] == EntryType.Folder)
                ProcessFolder(Folder.GetFolderInfo((int)row[SystemColumn.Id], session)); // recurse
        }
    }
}

This will still result in the 9051 error for deep folder trees because the entry listing is open when the ProcessFolder method is called to process the subfolder.

A better method is to read all of the folders from the listing and then close the listing before processing them:

void ProcessFolder(FolderInfo folder)
{
    List<int> folderIds = new List<int>();

    using (FolderListing listing = folder.OpenFolderListing(settings))
    {
        foreach (EntryListingRow row in listing)
        {
            if ((EntryType)row[SystemColumn.EntryType] == EntryType.Folder)
                folderIds.Add((int)row[SystemColumn.Id]);
            else
            {  /* handle the document here*/  }
        }
    } // the listing is now closed

    foreach (int folderId in folderIds)
    {
        ProcessFolder(Folder.GetFolderInfo(folderId, session)); // recurse
    }
}

 

2 0
replied on December 7, 2015

Thanks for the advice. I changed the code to a non-recursive style, and it worked.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.