Yes, you should be able to do that.
System.Exceptio n is marked as Serializable, and it implements ISerializable.
You can use GetObjectData to serialize the Exception.
You can use the protected constructor with the signature:
protected Exception(Seria lizationInfo info, StreamingContex t context)
to deserialize the Exception object.
You should also be able to serialize/deserialize using something like these
simple functions:
//
// public static void Serialize ( object instance, string filename )
// {
// Stream s = new FileStream(file name, FileMode.Create , FileAccess.Writ e);
// new System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er()
// .Serialize(s, instance);
// s.Close();
// }
//
// public static object Deserialize ( string filename )
// {
// Stream s = new FileStream(file name, FileMode.Open);
// object o = new
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er()
// .Deserialize(s) ;
// s.Close();
// return o;
// }
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Julia" <co********@012 .net.il> wrote in message
news:eW******** ******@TK2MSFTN GP12.phx.gbl...
Thanks,
What about serialization, can I serialize an exception including all sub
inner exceptions?
I read some articles regarding permissions and security but I am not sure
I
understood
what they talk about
Thanks
"Dennis Myrén" <de****@oslokb. no> wrote in message
news:WD******** **********@news 4.e.nsc.no... Then, it is probably a good approach.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Julia" <co********@012 .net.il> wrote in message
news:u6******** ******@TK2MSFTN GP14.phx.gbl... > Because i will be able to catch(if i want) all exceptions generated by my > system in a single place
> and other in a second place
>
>
> catch(JuliaSyst emException exception)
> {
> Log(e)
> }
> catch(System.Ex ception exception)
> {
> MessageBox(e.me ssage)
> }
>
>
>
> "Bonj" <Bo**@discussio ns.microsoft.co m> wrote in message
> news:1D******** *************** ***********@mic rosoft.com...
>> Why not just use one of the framework's inbuilt exceptions?
>>
>> "Julia" wrote:
>>
>> >
>> > Hi I have a system which composed from 2 different components
>> >
>> > 1.MailSender
>> >
>> > 2.MailReciever
>> >
>> >
>> >
>> > the Name of my system is JuliaSystem
>> >
>> > I wonder if it is a good approach to derive all my custom exceptions
> from
>> > JuliaSystemExce ption
>> >
>> > and than declare a abase exception for each component?
>> >
>> > for example for the mail sender I will have a base exception like
>> > the
>> > following
>> >
>> > MailSenderExcep tion:JuliaSyste mException
>> >
>> > for specific exception of the mail sender I will do the following
>> >
>> > FailedToConnect Exception:MailS enderException
>> >
>> >
>> >
>> >
>> >
>> > Thanks.
>> >
>> >
>> >
>
>