Srikanth Venugopalan
Srikanth Venugopalan

Reputation: 9049

Methodbase.Invoke on Loaded assembly method does not hit breakpoint

My setup is like this:

I am writing a Test Adapter for visual studio, that invokes a console application, which loads a test assembly and executes test methods.

So, here is some code on what I have been upto:

//load the test assembly
var assembly = Assembly.LoadFrom("path\to\testassembly")

//not actual code, but it is representative 
var method = assembly.GetTypes().SelectMany(type => type.GetMethods()).Where(info => info.Name=="foo");

//Create type instance
var instance = Activator.CreateInstance(method.DeclaringType);
method.Invoke(instance, args)

With this, when I put a breakpoint in the method, foo, Visual studio indicates that symbols have been loaded, and the breakpoint is active. But it never hits it.

And to verify if the method was called, I put some Console.Writelines, it does hit the method.

Any tips on how to make it hit the breakpoint?

Upvotes: 0

Views: 512

Answers (1)

feiyun0112
feiyun0112

Reputation: 771

put breakpoint on this line

method.Invoke(instance, args)

when hit, press F11

Upvotes: 1

Related Questions