Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Reflection getting MissingMethodException

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
brian.gabriel@gmail.com - 20 Mar 2006 23:27 GMT
I am trying to use reflection to dynamically call a method.  I have an
"interface" object that is inherited by the object that I am trying to
invoke.  The interface object contains virtual methods that throw a
custom NotImplemented exception.  The actual class overrides these
methods, the end goal is to loop through each method to see which ones
throw the NotImplemented exception.

Here is the code that I am using to dynamically invoke to method:

Type InterfaceType = typeof(Interfaces.MainInterface);
System.Runtime.Remoting.ObjectHandle hobj = null;
object[] arguments = new object[0];

hobj =
Activator.CreateInstance("Interfaces.MainClass1","Interfaces.MainClass1");
object result = InterfaceType
.InvokeMember("myMethod",BindingFlags.Instance|BindingFlags.Public|BindingFlags.InvokeMethod,null,hobj,arguments);

When I run the code I get a MissingMethodException exception saying it
can find method Interfaces.MainClass1.myMethod

Everything looks clean, any thoughts?

Thanks,

Brian
brian.gabriel@gmail.com
Dmytro Lapshyn [MVP] - 21 Mar 2006 12:05 GMT
Hi Brian,

I am not sure InvokeMember can accept object handles. Can you please try
CreateInstanceAndUnwrap to get a real object reference and then supply the
obtained reference to InvokeMember instead of the "hobj" handle?

>I am trying to use reflection to dynamically call a method.  I have an
> "interface" object that is inherited by the object that I am trying to
[quoted text clipped - 23 lines]
> Brian
> brian.gabriel@gmail.com
brian.gabriel@gmail.com - 21 Mar 2006 14:48 GMT
I tried unwrapping the object and passing the actual reference, no
luck.

Thanks,

Brian
brian.gabriel@gmail.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.