Serializing custom exception through a webmethod call.

M

Matt Bush

How do I xml serialize a custom exception so it can be included as a
parameter on my webmethod? See extra details below.

I have an audit web service which attempts to log exceptions to a database.

The web method looks like:

<WebMethod(Description:="Log process message.")> _
Public Function AddProcessMessage( _
ByVal ProcessExecutionKey As Long, _
ByVal AppEx As UserException) As Boolean

' Returns true if successfully logs the message and the AppEx log
flag will also be set to true.
Return ProcessExecution.AddProcessMessage(ProcessExecutionKey, AppEx )
End Function

This generates an error complaining about security permissions on the base
exception class, eg. properties such as 'TargetSite' can not be serialised.

Do I need to do imperative asserts or explicit demands or both. If so could
you give me a code example that relaxes the security on xml serializing a
custom exception.

Thanks.
 
D

Dan Rogers

Concur. Rather than base your types on the internal exception types (which
are not portable), I'd suggest designing an exception base class of your
own in XSD, just like you would design a business document such as an
order. Then, generate classes from this XSD using XSD.exe or
XSDObjectGen.exe, and build your service interface to accept the typed
classes that result. This will give you the interface you need without
introducing underlying platform item specific serialization issues.

Regards,

Dan Rogers
Microsoft Corporation
--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top