Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exceptions acrossed servers

Status
Not open for further replies.

Teamgc

Programmer
Feb 15, 2006
37
0
0
IE
I have business object and data access layer on one server, when i use these services from that server I get the correct error messages returned. But when i use this layers from a different machine the correct error is not passed across to the other machine.

does anyone have any ideas on this?
 
I need a little more information. Are the business object and data access layer on the one server part of an application running on that server and a client on another machine connects to that application? Or is this an application on a network share that is being called from the server but run on the different machine?



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
the business layer and data access layer are both WCF services on the same server.

then the application which is on a different machine uses the business layer which in turn uses the data access layer.

if the app and the BOL and DAL are all on the one machine the error messages are correct.

if either the BOL or DAL is on a different machine to the app, the error message that I should get is lost and i get a different one.
 
I'm not sure, but maybe this article will help:


Note: the article contains C# code, but it's not very complex and should be easy to apply to VB.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Do you have your FaultContract set up correctly?
Are you seeing your channel go to a Faulted state?

What we did was derive a class from System.Exception, and use it in our FaultContract everywhere. It's InnerException property contains the real exception that happened on the server.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
i've got a exception class which i reference in my WCF service. So in my DAL i throw an error and catch it as normal. I then "ProcessDataException(ex, "Database Policy")"

this puts it into the database and rethrows it. It goes into the database fine, but when i get the exception at the front end it says "No corresponding start element is open."

and my rethrow code is as follows...
Throw New FaultException(New FaultReason(KBSEx.Message), New FaultCode("FaultCode1"))

i haven't figured out fault contracts.
 
i've put in a fault contract like so

<OperationContract()> _
<FaultContract(GetType(MyFault))> _
Function DALExecuteDataset(ByVal param As DALParameter) As DataSet


Now, the param passed in is empty, i remove the fault contract and the param is populated.

Is there another field or option I'm missing?
 
When you catch an exception in your service implementation, are you wrapping it in a new FaultException of T object, with a FaultReason?

And on the calling side, are you catching the FaultException of T, where T is your custom exception class?

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
yes to both questions. I have a function just to throw errors and they are wrapped in faultexceptions of T object and caught as faultexceptions of T object.

The issue I have now is (in the below code), when a param gets to DALExecuteDataset it's empty and if I remove the fault contract it's fine.

<OperationContract()> _
<FaultContract(GetType(MyFault))> _
Function DALExecuteDataset(ByVal param As DALParameter) As DataSet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top