Debugger displays wrong lines when in a dynamically loaded assembly

  • Thread starter Thread starter TkPins
  • Start date Start date
T

TkPins

I am loading an assembly using the following code:

ObjectHandle oh = Activator.CreateInstanceFrom(assemblyName, className);
object obj = oh.Unwrap();
MyInterface interface = obj as MyInterface;
interface.MyFunction(); // Call a function in the
loaded assembly

I then call functions using my interface - which works fine.
But if I try to use the debugger, as soon as it steps into the assembly, the
debugger displays the incorrect line.
Although it does open the correct source code file. It just seems to have
the wrong line offset.

I have made sure that the source code and the DLL are the same (not
different versions).

What could be the problem? This isn't normal is it?

Thanks in advance.

Tom
 
Normally when this happens to me, it's because I made a change to the code
and forgot to recompile it. Have a look at the Solution Configuration
properties and make sure that the Build checkbox is checked for the project.
 
I made sure to recompile everything before testing to make sure that there
was nothing 'out of sync'.
No changes were made to any of the code after recompiling / before testing.

Also - there is some code in a dll used by the loaded assembly that uses #if
preprocessor directives to eliminate some code.
Could this cause the debugger to have this problem? Please note that the
source files where I am seeing the problem do not have any code #if
excluded.

Thanks,
Tom
 
FIXED...

Even though I thought I recompiled and updated everything with new, I must
not have.
I recompiled everything again, and moved the dll's as required, and now it
is working.

Thanks,
Tom
 
Back
Top