Note that there are some explanatory texts on larger screens.

plurals
  1. POProgrammatic configuration of Exception-sending in WCF
    text
    copied!<p>I would like my Silverlight client to be able to display exceptions that have happened at the server during a WCF call.</p> <p>Given my current code to create a WCF Channel (on the client):</p> <pre><code>// create the binding elements BinaryMessageEncodingBindingElement binaryMessageEncoding = new BinaryMessageEncodingBindingElement(); HttpTransportBindingElement httpTransport = new HttpTransportBindingElement() { MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }; // add the binding elements into a Custom Binding CustomBinding customBinding = new CustomBinding(binaryMessageEncoding, httpTransport); // create the Endpoint URL EndpointAddress endpointAddress = new EndpointAddress(serviceUrl); // create an interface for the WCF service ChannelFactory&lt;TWcfApiEndPoint&gt; channelFactory=new ChannelFactory&lt;TWcfApiEndPoint&gt;(customBinding, endpointAddress); channelFactory.Faulted += new EventHandler(channelFactory_Faulted); TWcfApiEndPoint client = channelFactory.CreateChannel(); return client; </code></pre> <p>When an exception occurs, I just get a "NotFound" exception, which is obviously of no use. How can I get the exception information?</p> <p>I use this code to use the client object returned above:</p> <pre><code>try { // customFieldsBroker is the client returned above customFieldsBroker.BeginCreateCustomField(DataTypeID, newCustomField, (result) =&gt; { var response = ((ICustomFieldsBroker)result.AsyncState).EndCreateCustomField(result); }, customFieldsBroker); } catch (Exception ex) { // would like to handle exception here } </code></pre> <p>Wrapping the Begin/End calls in a try { } catch { } block doesn't seem to even jump into the catch { } block.</p> <p>If it matters, I'm using Silverlight 3 at the client.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload