i'm using wcf service insert data db , service crashes saying exception un-handled. i'm trying pass on exception 1 wcf service method other wcf method , there throwing exception client.
here code:
data inserting method of wcf service: method insert data db
public int insertstatements(sqlcommand cmd) { try { //insert data db } catch(sqlexception ex) { if (ex.number == 2627) // if unique key constraint error { throw new faultexception( "error reason", new faultcode("error code: "); } else { throw new faultexception("db error: ", new faultcode("error code: " +); } } catch (faultexception ex) { throw new faultexception("unknown error",new faultcode("unknown error")); } }
wcf insert location method, service exposed method(public)
public int insertlocation (string name) { try { // method communicates client dataconnection.insertstatements(cmd); } catch { throw; // here i'm getting error } }
in client: winform application
try { areadataservicesclient dataobject = new areadataservicesclient("basichttpbinding_iareadataservices"); int rowsaffected = dataobject.insertprovince(provinceobject.areaname, provinceobject.areakm); return rowsaffected; } catch(faultexception ex) { messagebox.show("erro occured"); }
this error get: "an exception of type 'system.servicemodel.faultexception' occurred in emsdataservices.dll not handled in user code"
why service method not pass exception client.
i found it. there nothing wrong code. running services on debug mode , in exception setting 'break @ point if user code unhandled' checked,so stopping service perform further action , client crashing due no response service.
i unchecked , works expected.
Comments
Post a Comment