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

G

Guest

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?
 
G

Guest

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
 

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

Top