title: Invoke member through reflection passing derived class as argument
body: <p>I'm trying to call the method 'MyMethod' of class 'CMyClass'. This method has a parameter of type "CBaseClass", and I'm passing an object of type "CDerivedClass".</p>
  
  <pre><code>Class CBaseClass
      Public m_AMember As String
      Sub MethodOne()
          // DoSomething
      End Sub
  End Class
  
  Class CDerivedClass
      Inherits CBaseClass
      Public m_MyMember As Integer
      Sub MethodTwo()
          // DoSomething
      End Sub
  End Class
  
  Class CMyClass
      Sub MyMethod(ByVal obj As CBaseClass)
          // DoSomething
      End Sub
  End Class
  
  Sub Main()
      'load assembly
      Dim objAssembly As Assembly = Assembly.LoadFrom("myfile.dll")
  
      'create class instance and MethodInfo object
      Dim t As Type = objAssembly.GetType("MyNamespace.CMyClass")
      Dim obj As Object = Activator.CreateInstance(t)
      Debug.Assert(obj IsNot Nothing)
      Dim m As MethodInfo = t.GetMethod("MyMethod")
      Debug.Assert(m IsNot Nothing)
  
      'Init arguments (only one)
      Dim par As New CDerivedClass()
      Dim parameters As Object() = New Object(0) {par}
  
      'invoke method
      m.Invoke(obj, parameters) '&lt;&lt;&lt;&lt; ArgumentException here!
  End Sub
  </code></pre>
  
  <p>The argument exception says "object of type 'MyNamespace.CDerivedClass' cannot be converted to type 'MyNamespace.CBaseClass'.</p>
  
  <p>I changed "ByRef" to "ByVal" in MyMethod signature, but nothing changed.
  I tried to change type of 'par' object with:</p>
  
  <pre><code>Dim par As CBaseClass = New CDerivedClass()
  </code></pre>
  
  <p>without success.
  How I can invoke correctly the method "MyMethod" with an instance of derived class?
  Thank you very much.</p>