473,396 Members | 1,995 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.

Remoting: serialization problem for enum(with [Flags] attribute)

Hi,
I have following enum definition.

[Serializable]
[Flags]
public enum OperationTypes
{
All = 1,
New = 2,
View = 4,
Save = 8
}

public class MyTest
{
public OperationTypes GetTypes()
{
OperationTypes _Types = OperationTypes.Save | OperationTypes.New;
return _Types;
}
}
If I expose MyTest as remoting object, caller is getting exception when they
call the GetTypes() method. Exception suggest it cannot deserialize the
returned enum.

It seems SoapSerialization has problem when I use [Flags] attribute in enum
to use it as bitwise operator and if I set enum to more than one value. I I
set single value (like OperationTypes _Types = OperationTypes.Save;) it
works fine.

Is there any way I can overcome this problem?

---
Jigar
Sep 6 '06 #1
2 7393
MyTest is defined as [Serializable]

--
Jigar
"Ji*********@nospam.nospam" wrote:
Hi,
I have following enum definition.

[Serializable]
[Flags]
public enum OperationTypes
{
All = 1,
New = 2,
View = 4,
Save = 8
}

public class MyTest
{
public OperationTypes GetTypes()
{
OperationTypes _Types = OperationTypes.Save | OperationTypes.New;
return _Types;
}
}
If I expose MyTest as remoting object, caller is getting exception when they
call the GetTypes() method. Exception suggest it cannot deserialize the
returned enum.

It seems SoapSerialization has problem when I use [Flags] attribute in enum
to use it as bitwise operator and if I set enum to more than one value. I I
set single value (like OperationTypes _Types = OperationTypes.Save;) it
works fine.

Is there any way I can overcome this problem?

---
Jigar
Sep 6 '06 #2
You could write a serialisation surrogate so the the enum which is able to
custom deserialise the enum value for you. Not entirely sure how to hook it
into the remoting though.
Ciaran O'Donnell

"Ji*********@nospam.nospam" wrote:
Hi,
I have following enum definition.

[Serializable]
[Flags]
public enum OperationTypes
{
All = 1,
New = 2,
View = 4,
Save = 8
}

public class MyTest
{
public OperationTypes GetTypes()
{
OperationTypes _Types = OperationTypes.Save | OperationTypes.New;
return _Types;
}
}
If I expose MyTest as remoting object, caller is getting exception when they
call the GetTypes() method. Exception suggest it cannot deserialize the
returned enum.

It seems SoapSerialization has problem when I use [Flags] attribute in enum
to use it as bitwise operator and if I set enum to more than one value. I I
set single value (like OperationTypes _Types = OperationTypes.Save;) it
works fine.

Is there any way I can overcome this problem?

---
Jigar
Sep 8 '06 #3

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

Similar topics

1
by: Dave | last post by:
An test application uses remoting to call a component on a different machine. The client app has 2 buttons. The first calls the component using http/soap and it is remarkably fast. The second...
16
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ..........
3
by: Matt Burland | last post by:
I wanted to set up a enum to represent certain properties of an object that can be combined. So I'm using the FlagAttribute with my enum and adding them to by objects with | (or). But what is the...
6
by: Guest | last post by:
Hi, I unerstand that if you choose IIS to host your .Net Remotingcomponents with HTTP channel and SOAP formatter, you get thebuilt-in security and configuraion features of IIS. Also we canexpose it...
1
by: Ehsan | last post by:
Does this attribute really work? I'm trying to "deep" serialize one of my objects which has a member variable pointing to a Form object. I don't want to serialize this form (and I know that I...
4
by: Christian.Wall | last post by:
Hello, I've got the following enum: public enum MyStates { None = 0 Saved = 1 New = 2
3
by: Desmond Cassidy | last post by:
I created an Enum with the EnumBuilder which allows you to add items with spaces embedded as well as the name of the Enum. e.g. US States and a member of New York The normal way you would iterate...
5
by: Paul | last post by:
VB.NET - VS 2005 Is it possible to create an Enum with numeric members. Example: Public Enum NumberOfDecimalPlaces Auto 1 2 3 4
6
by: BillG | last post by:
I have the following defined. enum DisplayEventType{DISPUTE = 0x0001, ACTION = 0x0002, QUESTION = 0x0004); DisplayEventType dEventType; if(DisputesCheckBox.Checked) dEventType = dEventType...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.