c# - Invoke a method via MethodInfo Problem -


I get the criteria by using the class name and method name as well as the query string. I do not know what's coming, I can not say that to make this example or to give that example to pass it, give the MethodInfo invoke method so that I need a general solution. Here's the problem:

  string className = request .QueryString ["className"]; String Action Matthew = Request .QueryString ["actionName"];  

So I want to apply a class method to the information given above:

  System. Reflection.MethodInfo info = Type.GetType (className) .GetMethod (actionMethod); Info.Invoke (obj, null);  

But since I do not know what's coming from this querystring , I can not create an example of a class that I want to use the method .

How can I get this problem ...

You know, in the class you are in, in the assembly, you can use the Assembly.CreateInstance (string) to create your own example of class.

The code has not been tested

  object myObject = Assembly.CreateInstance (typeName); MethodInfo info = Type.GetType (className) .GetMethod (verb method); Info.Invoke (myObject, null);  


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -