F
Fabio Cannizzo
I load an assembly DLL dynamically using
System.AppDomain.CurrentDomain.Load(... ).
I create the istance of an object contained in the assembly and invoke one
of its method.
How can I make the debugger stop within the code of this DLL?
If my question is not clear, please have a look below... Thanks a lot
In ClassLibrary1.dll I have
interface MyInterface {
int MyMethod();
}
In ClassLibrary2.dll I have
public MyClass : MyInterface {
int MyMethod() { retrun 10; );
}
In Main.exe I have
.....
FileStream fs = new FileStream(@"ClassLibrary2.dll", FileMode.Open);
byte[] buffer = new byte[(int) fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Assembly asm = System.AppDomain.CurrentDomain.Load( buffer ); // load the
assembly
Type[] tp = asm.GetTypes();
foreach ( Type t in tp )
if (null != t.GetInterface( "MyInterface" ) ) { // scan for types
which implement MyInterface
// call default constructor with no parameters
Object obj = t.InvokeMember(null, BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance,
null, null, null);
// invole a method
int i = (int) ((MyInterface)obj).MyMethod(); // I would like the
debugger to stop during the execution of MyMethod. How can I do???
}
.....
System.AppDomain.CurrentDomain.Load(... ).
I create the istance of an object contained in the assembly and invoke one
of its method.
How can I make the debugger stop within the code of this DLL?
If my question is not clear, please have a look below... Thanks a lot
In ClassLibrary1.dll I have
interface MyInterface {
int MyMethod();
}
In ClassLibrary2.dll I have
public MyClass : MyInterface {
int MyMethod() { retrun 10; );
}
In Main.exe I have
.....
FileStream fs = new FileStream(@"ClassLibrary2.dll", FileMode.Open);
byte[] buffer = new byte[(int) fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Assembly asm = System.AppDomain.CurrentDomain.Load( buffer ); // load the
assembly
Type[] tp = asm.GetTypes();
foreach ( Type t in tp )
if (null != t.GetInterface( "MyInterface" ) ) { // scan for types
which implement MyInterface
// call default constructor with no parameters
Object obj = t.InvokeMember(null, BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance,
null, null, null);
// invole a method
int i = (int) ((MyInterface)obj).MyMethod(); // I would like the
debugger to stop during the execution of MyMethod. How can I do???
}
.....