Murugan.com
Murugan Andezuthu Dharmaratnam

  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  PHP   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  



dynamically call a functino in .net


Home  > VB.NET  > dynamically call a functino in .net 
       
public static string InvokeStringMethod2
    (string typeName, string methodName, string stringParam)
{
    // Get the Type for the class
    Type calledType = Type.GetType(typeName);

    // Invoke the method itself. The string returned by the method winds up in s.
    // Note that stringParam is passed via the last parameter of InvokeMember,
    // as an array of Objects.
    String s = (String)calledType.InvokeMember(
                    methodName,
                    BindingFlags.InvokeMethod | BindingFlags.Public | 
                        BindingFlags.Static,
                    null,
                    null,
                    new Object[] { stringParam });

    // Return the string that was returned by the called method.
    return s;
}

---------------
// All error checking omitted. In particular, check the results
// of Type.GetType, and make sure you call it with a fully qualified
// type name, including the assembly if it's not in mscorlib or
// the current assembly. The method has to be a public instance
// method with no parameters. (Use BindingFlags with GetMethod
// to change this.)
public void Invoke(string typeName, string methodName)
{
    Type type = Type.GetType(type);
    object instance = Activator.CreateInstance(type);
    MethodInfo method = type.GetMethod(methodName);
    method.Invoke(instance, null);
}

or

public void Invoke(string methodName) where T : new()
{
    T instance = new T();
    MethodInfo method = typeof(T).GetMethod(methodName);
    method.Invoke(instance, null);
}


ASP / VB .NET Get The State Of the Current Thread and check if its running

Configuration Manager Not found in IDE of Visual Studio .NET 2005

Debug Problem WebService Visual Studio 2005 The breakpoint will not be hit No symbol has been loaded for this document

index

Invoke or BeginInvoke cannot be called on a control until the window handle has been created.

VB .NET Delay The TextChanged Event of a TextBox using Timer Control

VB .NET How to Create XML Files with fields Dynamically

VB .NET Timer Control delay or Interval in milliseconds

VB .NET TreeNode Display Image or icon in a TreeView Control

VB .NET WinForm How to Pass a Paramter to a Thread

VB .NET Winform Make a TreeNode Invisible or Hide a TreeNode in a TreeView Control

VB .NET Sort a combobox xml datasource

.net temporarily disable an event handler

showwindow fullscreen windows 7

.net double click show full window

.net hide windows 7 start menu

.net winform statusstrip separator

Implement Keyboard Shortcut in Windows

dynamic call a function

dynamically call a functino in .net

.NET Display a form



  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  PHP   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  

Copyright 2009 @ Murugan Andezuthu Dharmaratnam