c# - How to catch Exception from remote WCF service? -


after add reference visual studio ui, initialized client:

private wcfrequestprocessorclient _client;  var binding = new basichttpbinding(); binding.security.mode = basichttpsecuritymode.transportcredentialonly;  string servicefullurl = "http://myserviceurl.com/svcapi"; var address = new endpointaddress(servicefullurl);  _client = new wcfrequestprocessorclient(binding, address); _client.clientcredentials.username.username = "myusername"; _client.clientcredentials.username.password = "mypassword"; 

and later, call related method request parameter:

try {     var itemsreq = loaditemsrequest();     _client.processrequestsasync(itemsreq); } catch(exception) {      // source code show error in popup } 

now, when url, username, , password are correct, all work fine. if url, username, or password are wrong, the app breaks , visual studio show me window when debugging, jumping catch block:

enter image description here

which way handle these type of exceptions?

the service needs configured propagate real exceptions you.

it how ever state if exception thrown though don't know actual reason you've stated. 'an exception been thrown'

the reason exception not caught call asynchronous.

i.e. exception thrown on different stack 1 called on.

if returns task need await it.

if it's apm style asynchronicity have provide callback , attempt catch there.

additionally can register appdomain.unhandledexception catch exception eventually.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -