Debananda / fluorinefx

Automatically exported from code.google.com/p/fluorinefx
0 stars 0 forks source link

Exceptions thrown from RemotingClient callbacks are swallowed as netexe #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Edit 
FluorineFx\Samples\Silverlight\AMFCall\SilverlightApplication\Page.xaml.cs 
to throw an exception from GetXDocumentHandler.ResultReceived()

What is the expected output? What do you see instead?
Expect to result in an exception bubbling up the call stack.
Exception is swallowed and exposed as a NetStatus event.

What version of the product are you using? On what operating system?
WinXP, VS2008, SilverLight 3, FluorineFX 1.0.0.15

Please provide any additional information below.
Silverlightut unit tests become messier when asserts thrown from the 
callback handler are swallowed.

To work around this issue, I created a callback wrapper class posts the 
actual callback work to the originating thread so call-back exceptions are 
thrown from that thread, instead of the FluorineFX callback context. Eg:
public class GenericPendingServiceCallback : IPendingServiceCallback
    {
        private Action<IPendingServiceCall> callback;
        public GenericPendingServiceCallback(Action<IPendingServiceCall> 
callback)
        {
            this.callback = callback;
        }
        public void ResultReceived(IPendingServiceCall call)
        {
            // callbacks affecting the UI should be posted to the UI 
thread, not a background thread.
            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += (o, e) =>
                {
                    callback(call);
                };
            worker.RunWorkerAsync();
        }
    }

[TestMethod]
[Asynchronous]
public void ShouldReturnFailureWhenCallingNonexistantService()
{
    connection.Call("ServiceName.ServiceMethodName",
        new GenericPendingServiceCallback((call) =>
            {
                Assert.IsFalse(call.IsSuccess);
                TestComplete();
            }));
}

Original issue reported on code.google.com by daniel.l...@gmail.com on 20 Oct 2009 at 3:53