通过BeginInvoke和EndInvoke调用进行调试 [英] Debuggin across BeginInvoke and EndInvoke calls

查看:41
本文介绍了通过BeginInvoke和EndInvoke调用进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个模块通过代理进行通信.

第一个模块标记为"CL",因此我假设这是客户端,它使用Activator.GetObjectcall创建代理.

这似乎起作用,因为输出不为null.

然后使用

BeginInvoke<code>.<br />
<br />
We wait using <code>WaitOne

创建并调用此代理的委托,然后使用EndInvoke检索结果.

委托函数返回错误,但是由于无法调试BeginInvoke call,所以不知道为什么.

我尝试在另一个标有"SV"的模块中放置一个断点,因此我认为这是服务器,但不会停止.

代理相同.

像这样

 ...
m_proxy =(MyProxy)Activator.GetObject( typeof (MyProxy),stringProxyAddress);
...

MyDelegate dlgt = ;
IAsyncResult iAsyncResult = ;
布尔 bAsyncResult =  false ;
 int  retCode =  0 ;
// 假定MyProxy中有一个名为int Foo(对象输入1,对象输入2)的函数
dlgt =  MyDelegate(m_proxy.Foo);
iAsyncResult = dlgt.BeginInvoke(input1,input2, null  null );
...
bAsyncResult = iAsyncResult.AsyncWaitHandle.WaitOne(timeout, false );
...
如果(bAsyncResult)
{
retCode = dlgt.EndInvoke(iAsyncResult);
}
... 



retCode返回错误值,但是我无法跟踪错误原因,因为我无法在Foo内部进行调试.

我应该如何调试呢?

任何建议,不胜感激!


=====================


好的,我已经完成了更多的阅读和调试工作,还有更多问题.

1)Activator.GetObject通话不需要配对RegisterChannel即可完成通信吗?

2)我试图将服务器项目附加到服务器进程,但是即使显示所有进程"已打开,服务器进程也不会在要从Visual Studio附加的进程列表中出现.尽管能够在任务管理器中查看所需的过程.

3)而且我回来了整整一圈,但仍然想知道如何调试代理...

有任何想法吗?

解决方案

您的方案即将调试多个程序.
您可以通过附加适当的dll/项目来调试Foo.

调试多个程序 [Activator.GetObjectcall.

That seems to work as the output is not null.

Then a delegate for this proxy is created and called using

BeginInvoke<code>.<br />
<br />
We wait using <code>WaitOne

, then retrieve the result using EndInvoke.

The delegate function returns with an error, but because I can''t debug beyond the BeginInvoke call, I don''t know why.

I tried putting a break point in the other module, labeled "SV" so I assume that''s the server, but doesn''t stop.

Same for the proxy.

So it goes something like

...
m_proxy = (MyProxy)Activator.GetObject(typeof(MyProxy), stringProxyAddress);
...

MyDelegate dlgt = null;
IAsyncResult iAsyncResult = null;
bool bAsyncResult = false;
int retCode = 0;
// assume there is a function in MyProxy called int Foo(object input1, object input2)
dlgt = new MyDelegate(m_proxy.Foo);	
iAsyncResult = dlgt.BeginInvoke(input1, input2, null, null);
...
bAsyncResult = iAsyncResult.AsyncWaitHandle.WaitOne(timeout, false);
...
if(bAsyncResult)
{
retCode = dlgt.EndInvoke(iAsyncResult);
}
...



retCode comes back with an error value, but I can''t trace the cause of the error because I can''t debug inside Foo.

How shall I go about debugging this?

Any advice greatly appreciated!


======================


OK, I''ve done more reading and debugging and have a few more questions.

1) Doesn''t the Activator.GetObject call need a pairing RegisterChannel to complete the communication?

2) I tried to attach the server project to the server process but the server process won''t turn up in the list of processes to attach to from Visual Studio even with the "show all processes" turned ON. That''s despite being able to see the required process in Task Manager.

3) And I''ve come back full circle and am still left wondering how to debug the proxy...

Any ideas? Please?

解决方案

Your scenario is close to debugging multiple programs.
You could debug Foo by attaching the appropriate dlls / project.

Debugging Multiple Programs[^] could give you a start.


这篇关于通过BeginInvoke和EndInvoke调用进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆