.Net dynamic call and debuging issue

T

Tom

Hi .Net Professional :

In recent , I starting to learn about dynamic call .net object in vb.net.

Before, some IT people teach me use the following method and its work !!

Dim asm As [Assembly] =
[Assembly].LoadFrom("D:\vb7Project\dynamicCall\prj01\prj01\bin\prj01.dll")

Dim ty As Type = asm.GetType("prj01.dbLib")
Dim obj As Object = Activator.CreateInstance(ty)
obj.SendMsg()

However, I have face another problem : debug in runtime, I find that it can
allow me trace the program during runtime, e.g. I add breakpoint in the
child object. It will not show it. Therefore, how can I fix it. Actually , I
cannot change the dynamic design into static design(i.e. add reference to
project in design time).

Thanks for your help
..Net student
 
G

Guest

What do you mean by not allowing breakpoint in child object. Do you mean in
the SendMessage line of inside the object that you are creating. If you want
to debug the object you are creating, you just need to step into the code and
it should be able to debug. Otherwise, open that project(the dynamic code
one) and attach to the caller process and debug.

Rgds,
Anand
http://www.dotnetindia.com
 
T

Tom

Ok I tried to give you an example :

The host project create a vbform , in the vbform have create the button and
name as "Button1" ,
the button event is follow :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim asm As [Assembly] =
[Assembly].LoadFrom("D:\vb7Project\dynamicCall\prj01\prj01\bin\prj01.dll")
Dim ty As Type = asm.GetType("prj01.dbLib")
Dim obj As Object = Activator.CreateInstance(ty)
obj.SendMsg()

End Sub

Then I create the child project and attach it in the .net solution which
type is class libary name as "prj01" , in this project, I create the class
name "dbLib"
The code like this
Public Class dbLib
Public Function SendMsg()
MsgBox("a")
End Function
End Class
I have set the break point in the statment "MsgBox("a") " , but it is not
active in runtime.
Of course, I must know that add reference method can trace it. But this is a
dynamic design (like "createobject" method)
Can you tell me how can trace the code in the project "prj01".

Thanks

Anand said:
What do you mean by not allowing breakpoint in child object. Do you mean in
the SendMessage line of inside the object that you are creating. If you want
to debug the object you are creating, you just need to step into the code and
it should be able to debug. Otherwise, open that project(the dynamic code
one) and attach to the caller process and debug.

Rgds,
Anand
http://www.dotnetindia.com

Tom said:
Hi .Net Professional :

In recent , I starting to learn about dynamic call .net object in vb.net.

Before, some IT people teach me use the following method and its work !!

Dim asm As [Assembly] =
[Assembly].LoadFrom("D:\vb7Project\dynamicCall\prj01\prj01\bin\prj01.dll")

Dim ty As Type = asm.GetType("prj01.dbLib")
Dim obj As Object = Activator.CreateInstance(ty)
obj.SendMsg()

However, I have face another problem : debug in runtime, I find that it can
allow me trace the program during runtime, e.g. I add breakpoint in the
child object. It will not show it. Therefore, how can I fix it. Actually , I
cannot change the dynamic design into static design(i.e. add reference to
project in design time).

Thanks for your help
..Net student
 
G

Guest

You basically set the proj1 project properties and set host project to run
when debugging (Project properties/debugging). Then when you run proj1, the
host project starts and your break point gets hit.

Otherwise, attach the running host project in your proj1 project and when
the host creates the object, your breakpoint is hit.

Rgds,
Anand
http://www.dotnetindia.com

Tom said:
Ok I tried to give you an example :

The host project create a vbform , in the vbform have create the button and
name as "Button1" ,
the button event is follow :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim asm As [Assembly] =
[Assembly].LoadFrom("D:\vb7Project\dynamicCall\prj01\prj01\bin\prj01.dll")
Dim ty As Type = asm.GetType("prj01.dbLib")
Dim obj As Object = Activator.CreateInstance(ty)
obj.SendMsg()

End Sub

Then I create the child project and attach it in the .net solution which
type is class libary name as "prj01" , in this project, I create the class
name "dbLib"
The code like this
Public Class dbLib
Public Function SendMsg()
MsgBox("a")
End Function
End Class
I have set the break point in the statment "MsgBox("a") " , but it is not
active in runtime.
Of course, I must know that add reference method can trace it. But this is a
dynamic design (like "createobject" method)
Can you tell me how can trace the code in the project "prj01".

Thanks

Anand said:
What do you mean by not allowing breakpoint in child object. Do you mean in
the SendMessage line of inside the object that you are creating. If you want
to debug the object you are creating, you just need to step into the code and
it should be able to debug. Otherwise, open that project(the dynamic code
one) and attach to the caller process and debug.

Rgds,
Anand
http://www.dotnetindia.com

Tom said:
Hi .Net Professional :

In recent , I starting to learn about dynamic call .net object in vb.net.

Before, some IT people teach me use the following method and its work !!

Dim asm As [Assembly] =
[Assembly].LoadFrom("D:\vb7Project\dynamicCall\prj01\prj01\bin\prj01.dll")

Dim ty As Type = asm.GetType("prj01.dbLib")
Dim obj As Object = Activator.CreateInstance(ty)
obj.SendMsg()

However, I have face another problem : debug in runtime, I find that it can
allow me trace the program during runtime, e.g. I add breakpoint in the
child object. It will not show it. Therefore, how can I fix it. Actually , I
cannot change the dynamic design into static design(i.e. add reference to
project in design time).

Thanks for your help
..Net student
 
S

Simon Verona

Not sure this is much help, but I do exactly the same as you and debugging
works fine.

The only problem I have in debugging which may or may not be related to this
is when I'm running multiple threads, when single stepping seems to get a
bit problematic if two threads are running the code that I'm single stepping
through at the same time.

Regards
Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top