Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I have 2 modules communicating via a proxy.

The first module, labeled "CL" so I assume that's the client, creates a proxy with a 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

C#
...
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?
Posted
Updated 11-Jul-12 16:51pm
v2
Comments
Sergey Alexandrovich Kryukov 9-Jul-12 0:11am    
What do you mean that you "cannot debug beyond BeginInvoke call"? If you properly use it, the call defined by parameters of BeginInvoke is actually done on the UI thread. And you can always set a break point in the invoked method.
--SA
PaulowniaK 9-Jul-12 1:05am    
Er... if that worked, I won't be asking the question.

The problem is that I can't debug in proxy nor SV, and I'd love to know why not!
Sergey Alexandrovich Kryukov 11-Jul-12 15:55pm    
Sure but... did you run it under the debugger with a breakpoint on the invoked method?
--SA
PaulowniaK 11-Jul-12 21:00pm    
Sort of.

The break point marker on the left ledger doesn't turn red. Something about the symbol not being loaded.

So the debugger doesn't stop.

1 solution

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.
 
Share this answer
 
Comments
PaulowniaK 9-Jul-12 0:01am    
I can attach each of my projects (proxy, client and server) separately to the application, but I don't think I can do more than one at a time as they are in different solutions.

When I attach to the client, I can stop at the designated break point. Proxy and Server say they are not loaded when I attach them.
Sergey Alexandrovich Kryukov 9-Jul-12 0:12am    
I usually use two or three instances of Visual Studio and can debug almost anything... what's the problem, I cannot really understand.
--SA
PaulowniaK 9-Jul-12 2:01am    
Neither can I, and that's why I'm here! :-) Seriously, even if I start multiple VS instances, I can only attach one of those at a time to the application so I can only debug one project at a time.
Abhinav S 9-Jul-12 1:44am    
The only other thing I can think of are the server calls.
For e.g you may be pointing the client to the server but still trying to debug on the local machine.

Set up a local server on your machine and then debug.
That is what I do in such circumstances.
PaulowniaK 9-Jul-12 2:00am    
I may be getting it very wrong, but they are all on my PC already...?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900