none
DirectoryVirtualListView not working correctly RRS feed

  • Question

  • Hi Folks,

    I am having a similar issue as mentioned Here in that a query for users name beginning with 'G' just brings back a set of random results (actually I get 10 records sorted into alphabetical order starting from 'A').

    DirectorySearcher search = new DirectorySearcher(directoryEntry);
                            search.SearchRoot = null;
                            search.Asynchronous = false;
                            search.Filter = String.Format("(objectClass=User)");
    
                            SortOption sortOption = new SortOption() { Direction = SortDirection.Ascending, PropertyName = "displayName" };
                            search.Sort = sortOption;
    
                            DirectoryVirtualListView dvlv = new DirectoryVirtualListView();
                            dvlv.Target = searchCriteria.Trim();
                            dvlv.BeforeCount = 0;
                            dvlv.AfterCount = 10;
                            search.VirtualListView = dvlv;
    
    SearchResultCollection collection = search.FindAll()

    Just wondering if anyone knows what the issue would be?

    Also, while 'collection' will contain 10 results, if I then make a call to search.VirtualListView.ApproximateTotal;  I get a COM exception as this property is not defined. If I breakpoint on the line, count 10 seconds and then check the value it will contain value  (the entire number set of the users in A/D - rather than the 5 users I expect to get back).

    This is indicating to me that the search is running asynchronously rather than blocking until it has a valid result set.  Is there some way I can force it to wait until the search has completed so it does not throw an exception?

    Regards

    Andy

    • Moved by Amanda Zhu Thursday, November 21, 2013 7:31 AM
    Thursday, November 21, 2013 1:42 AM

Answers

  • Hi Andy,

    MSDN has said it was “the estimated total count of items in the list”. The search will be more efficient if this property is set to false to avoid the transfer of the result set to the client computer. So I think system cannot give you the exact number. You could see in this page. http://msdn.microsoft.com/en-us/library/vstudio/system.directoryservices.directoryvirtuallistview.approximatetotal(v=vs.90).

    > as I am now not getting a large result set I cannot confirm if it is still asynchronous due to it returning a result quite quickly.

    You set the Asynchronous property to false, so I think the DirectorySearcher should be DirectorySearcher. And if you don’t set CacheResults property, the search will cache the result on client computer. So it will be a short time when the next search.

    Hope useful to you.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 22, 2013 6:59 AM
    Moderator

All replies

  • As usual 5 minutes after the post I find a solution.

    I have changed the search to be "(&(objectClass=user)(anr={0})", searchCriteria.Trim()  which returns the precise result set. Also have commented out the dvlv.Target line. 

    I am still not sure about the ApproximateTotal  - as I am now not getting a large result set I cannot confirm if it is still asynchronous due to it returning a result quite quickly.

    Thursday, November 21, 2013 2:41 AM
  • Hi,

    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System and Visual Studio Editor.

    I am moving this thread to .NET Framework Class Libraries forum which should be a better forum for your issue.

    Thank you for your understanding.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 21, 2013 7:31 AM
  • Hi Andy,

    MSDN has said it was “the estimated total count of items in the list”. The search will be more efficient if this property is set to false to avoid the transfer of the result set to the client computer. So I think system cannot give you the exact number. You could see in this page. http://msdn.microsoft.com/en-us/library/vstudio/system.directoryservices.directoryvirtuallistview.approximatetotal(v=vs.90).

    > as I am now not getting a large result set I cannot confirm if it is still asynchronous due to it returning a result quite quickly.

    You set the Asynchronous property to false, so I think the DirectorySearcher should be DirectorySearcher. And if you don’t set CacheResults property, the search will cache the result on client computer. So it will be a short time when the next search.

    Hope useful to you.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 22, 2013 6:59 AM
    Moderator