The Artima Developer Community
Sponsored Link •

C# Answers Forum
C# Reflection Question

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
john celenza

Posts: 1
Nickname: johnp
Registered: Sep, 2005

C# Reflection Question Posted: Sep 19, 2005 12:35 PM
Reply to this message Reply
Advertisement
I'm trying to get my hands around something that will tremendously simplify my code. If anyone knows a direction that would be of help, i would greatly appreciate it.

I'm loading plug-in DLLs, which have a C# wrapper, into the Assembly class of the System.Reflection Namespace. I can see the classes in the DLL that i need to access in the Types Array, in this case a class MyClass, and i can easily call it's methods in the MethodInfo Array with .Invoke(). But it would be very handy if i could cast from the Assembly to an instance of the class MyClass, and i haven't found a way to do that that works. I figured that the object returned from the Activator.CreateInstance() would be the perfect candidate, but it generates a runtime "Illegal cast" error. The object examined in Quickwatch in the Visual Studio IDE looks exactly like a MyClass, but it won't cast. Any ideas?

In addition, if anyone knows whether there's a way to pass a ref parameter into a MethodInfo.Invoke() that would also be helpful.

Topic: forms Previous Topic   Next Topic Topic: creation of .msi setup file in .net

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use