Results 1 to 2 of 2

Thread: [2005] invoking method

  1. #1

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    [2005] invoking method

    hopefully someone can help me out here. i'm trying to use reflection to invoke the dispose method within a class but it keeps throwing an exception
    here's my code
    vb Code:
    1. If m_DataSource.GetType.GetInterface("IDisposable") IsNot Nothing Then
    2.                 Dim obj As Type = m_DataSource.GetType.GetInterface("IDisposable")
    3.                 If obj IsNot Nothing Then
    4.                     obj.InvokeMember("Dispose", Reflection.BindingFlags.DeclaredOnly Or Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance Or Reflection.BindingFlags.InvokeMethod, Nothing, Nothing, Nothing)
    5.  
    6.                 End If
    7.             End If

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  2. #2
    Lively Member CompositeID's Avatar
    Join Date
    Nov 2004
    Location
    The Neutral Corner
    Posts
    112

    Re: [2005] invoking method

    It appears that you are just trying to invoke the method on a type and not on an instance of that type. What is the exception you are getting?
    Dictionary
    Recursion - Until IsUnderstood; see Recursion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width