locked
AD App Errors RRS feed

  • Question

  • User1101335286 posted

    I am getting an error on some forms I am writing in asp.net.  The app is basically to allow some lookup and write abilityinto ADfor AD admins. On this form,you enter a username and it pulls a bunch of AD fields to display.  This also includes group membership.  On this group list, you can highlight a group in the listbox nand click a button to view other members of this group.  On certain groups this thrws an error.  It is only on certain groups for no reason.  The groups are standard security groups with only a few members.  Here are 2 errors that I get on 2different groups.  Most others work fine though.

     

     

    No accessible overloaded 'ListItemCollection.Add' is most specific for these arguments:
       Public Sub Add(item As String)
       Public Sub Add(item As System.Web.UI.WebControls.ListItem)

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Reflection.AmbiguousMatchException: No accessible overloaded 'ListItemCollection.Add' is most specific for these arguments:
       Public Sub Add(item As String)
       Public Sub Add(item As System.Web.UI.WebControls.ListItem)

    Source Error:

    Line 325:            For Each User1 In arrmember
    Line 326: objUser = GetObject("LDAP://" & User1)
    Line 327: GroupMemListBox.Items.Add(objUser.sAMAccountName)
    Line 328: Next
    Line 329: objRecordset.MoveNext()

    Source File: \\computer\AD\admin.aspx.vb    Line: 327

    Stack Trace:

    [AmbiguousMatchException: No accessible overloaded 'ListItemCollection.Add' is most specific for these arguments: 
    Public Sub Add(item As String)
    Public Sub Add(item As System.Web.UI.WebControls.ListItem)]
    Microsoft.VisualBasic.CompilerServices.VBBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] match, Object[]& args, ParameterModifier[] modifiers, CultureInfo culture, String[] names, Object& ObjState) +6971
    Microsoft.VisualBasic.CompilerServices.VBBinder.InvokeMember(String name, BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target, Object[] args, String[] namedParameters) +576
    Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn) +616
    Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) +22
    AD._Default.GroupButton_Click(Object sender, EventArgs e) in \\computer\AD\admin.aspx.vb:327
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

     

     

    Unable to cast object of type 'System.DBNull' to type 'System.Collections.IEnumerable'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Collections.IEnumerable'.

    Source Error:

    Line 323:            strDN = objRecordset.Fields("distinguishedName").value
    Line 324: arrmember = objRecordset.Fields("member").value
    Line 325: For Each User1 In arrmember
    Line 326: objUser = GetObject("LDAP://" & User1)
    Line 327: GroupMemListBox.Items.Add(objUser.sAMAccountName)

    Source File: \\computer\AD\admin.aspx.vb    Line: 325

    Stack Trace:

    [InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Collections.IEnumerable'.]
    AD._Default.GroupButton_Click(Object sender, EventArgs e) in \\computer\AD\admin.aspx.vb:325
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
     

     

    Any ideas? 

    Thursday, September 14, 2006 10:24 AM

All replies

  • User1354132231 posted

    The error seems to indicate you should be checking for null (Nothing) first.  It cannot tell if you are using a string or the ListItem when the value is null.  Are you using Option Strict?  If not, you should be - it avoids wonky errors like this and keeps you from using VB.NET's bad habits.

     

    Thursday, September 14, 2006 4:42 PM