I have a very odd problem which I hope someone can help me with. I have
written a very simple test program using remoting as an excercise in using a
custom sink - just a simple server with a single method called GetReply() and
a simple client. After configuring the remoting the code in the client looks
like this:
try
{
responseTextBox.Text = server.GetReply();
}
catch (Exception MyErr)
{
MessageBox.Show(MyErr.Message, MyErr.GetType().ToString());
}
Now, if I run the client without running the server I expect to get an
exception, which indeed I do - a SocketException with the message "No
connection could be made because the target machine actively refused it", and
without the custom sink this exception is caught in the above code and the
message box displayed, just as you would expect.
However, when I add in the custom sink the behaviour changes - but ONLY when
I am debugging in Visual Studio. Now the exception is flagged up in my
IClientChannelSink.ProcessMessage() method by the debugger as an unhandled
exception when it calls the ProcessMessage() method on the next sink. If I
continue execution after the exception the message box is shown as before.
Also, if I run the program outside the development environment it behaves as
expected.
The custom sink will eventually be used in a 'real'application, in which it
is quite acceptable for the client to run without the server, catch the
exception and react accordingly. However, it is making debugging very
difficult if, whenever I run the client in the development environment, it
halts at this exception.
I have already posted this in the MSDN forums, and I hope I haven't gonr
against any protocols by posting it here as well, but I can't get any
solution and it's really a probelm. It does seem like a bug that maybe should
be reported to Microsoft. If anyone can shed any light on this I would be
most grateful. I am using C# in Visual Studio 2005 with .NET2.0. The demo
program is available on request.
--
Dave