By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,529 Members | 1,826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,529 IT Pros & Developers. It's quick & easy.

How to create dynamic parameters and pass to invoke a method using reflection

P: 1
Hi,

I am trying to access all the properties, methods of an assembly using reflection. But what i want to do is invoke a method which contains custom parametrs like enumeration defined in a different assembly.

For ex:

Expand|Select|Wrap|Line Numbers
  1.  Dim assemblyToLoad As Assembly = Nothing
  2.  
  3.             assemblyToLoad = Assembly.LoadFrom(AssemblyName)
  4.  
  5.             Dim types As Type() = assemblyToLoad.GetTypes()
  6.             Dim type1 As Type
  7.  
  8.             For Each type1 In types
  9.                 If type1.IsClass And (String.Compare(type1.FullName, ClassName.Trim()) = 0) Then
  10.  
  11.                     Dim mi As MethodInfo() = type1.GetMethods()
  12.                     Dim mi1 As MethodInfo
  13.                     For Each mi1 In mi
  14.                         If mi1.IsStatic Then
  15.  
  16.                             Dim ex As ParameterInfo
  17.  
  18.  
  19.                             For Each ex In CType(mi1, MethodInfo).GetParameters()
  20.  
  21.                                 Dim parameterType As String = ex.ParameterType.ToString()
  22.                                 Dim parameterName As String = ex.Name.ToString()
  23.  
  24. ' After knowing the parameter type to be for ex: NewAssembly.Class.Enum
  25. ' How i pass this type to invoke the methos??
  26.  
  27.                             Next
  28.  
  29.                         End If
  30.  
  31.                     Next
  32.  
  33.                 End If
  34.  
  35.             Next
Oct 5 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.