473,396 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Should cstom exception type have serializable attribute?

I defined my own exception type as follows:

public class MyException: ApplicationException
{
public MyExceptionn() : base()
{
}

public MyException(string message) : base(message)
{
}

public MyException(
string message,
Exception innerException) : base(message, innerException)
{
}
}

I do not add any custom fields or properties.

Do I have to apply the [Serializable] custom attribute to the type?
Do I have to define special protected constructor which takes
SerializationInfo
and StreamingContext parameters?
Nov 17 '05 #1
1 897
Hi Dave,
I defined my own exception type as follows:

public class MyException: ApplicationException
{
public MyExceptionn() : base()
{
}

public MyException(string message) : base(message)
{
}

public MyException(
string message,
Exception innerException) : base(message, innerException)
{
}
}

I do not add any custom fields or properties.

Do I have to apply the [Serializable] custom attribute to the type?
Do I have to define special protected constructor which takes
SerializationInfo
and StreamingContext parameters?


Seems you've got the wrong group; you should use the C# one, this one is for
VC++.

As for your question, well, only if you want the exception to be
serializable (which is required if you expect to throw it across remoting
boundaries). It's a good practice, though.

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Opa | last post by:
Hi I'm having problem serialization an object instance which contains a public property on the object type My object hierarchy is many levels deep, so for simplicty I created to following which...
2
by: jakk | last post by:
Below is the exception that Iam getting. It says that the DataView that Iam storing in the session is not Serializable. BUt works fine if I store in the inproc session and fails if I switch to...
2
by: gary.goodwin | last post by:
HI I am trying to understand Attribute usage. For example the class SerializableAttribute is a class correct? So why when it is actually u sed the "Attribute" portion of the name is dropped. The...
4
by: rich.quackenbush | last post by:
I was very excited when version 2.0 of the framework came out... it looked as though the OptionalField atribute would help me sort out my serialization woes. So far, it hasn't through. All I'm...
2
by: Jigar.Patel | last post by:
Hi, I have following enum definition. public enum OperationTypes { All = 1, New = 2, View = 4,
6
by: semedao | last post by:
Hi All, I had working code that made custom serialization on objects that inherit from queue in the inherited queue I create my own GetObjectData: public void GetObjectData(SerializationInfo info,...
2
by: O.B. | last post by:
I have a an attribute within a Serializable class that is of type System.Net.IPAddress. When I try to serialize the class, I get the following error: System.InvalidOperationException: Cannot...
2
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
I defined a WCF callback contract: <ServiceContract()_ Interface IEBAPEvents 'this interface defines the events to be triggered in the clients 'the EBAP pattern defines two events: a progress...
1
by: Cirene | last post by:
I'm binding a datagrid to my business object. I get an error that the type 'abcshoppingcart'...is not marked as serializable. So, I added a attribute in the class. But then a blue squiggly...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.