ISerializable on value types

  • Thread starter Thread starter Eran Kampf
  • Start date Start date
E

Eran Kampf

I noticed this wierd problem when implementing ISerializable for a value
type.
The MSDN documentation (and FxCop) say The GetObjectData method should be
marked with [SecurityPermissionAttribute(SecurityAction.Demand,
SerializationFormatter=true)]
(http://www.gotdotnet.com/team/fxcop/docs/rules/SecurityRules/GetObjectData.html).

When I mark my value type's GetMethodData method with the above CAS
deleration I get a wierd SEHException during serialization.
Without the above CAS decleration, serialization\deserialization runs
fine...

Reference types on the other hand work fine with the above CAS
decleration...

Any idea why this is happening?

Eran Kampf
http://www.ekampf.com
 
Hi Eran,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you're having problem whan adding
permission checking to a value type serialization. If there is any
misunderstanding, please feel free to let me know.

Based on my research, I haven't get any result on this. I have tried it on
my computer and seems works well. Could you give me a repro here so that I
can try to work on this issue, since SEHException is a very general
exception. We need further research to see what is going wrong with it.

Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Eran,

Thanks for your repro code. I have reviewed this issue and are currently
researching on it. I will update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Eran,

Sorry that I haven't updated you for some days. Yes, I have reproduced it.
This issue seems to be complex and I have reported it to the product team.
Currently I'm waiting for their responses. I will update you as soon as I
get any update. Thank you very much for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
At this point, we are waiting for a reply from the Product team on this
issue. I should get an answer by tomorrow.

Anand Balasubramanian
Microsoft, Visual C# .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
The product team looked at the issue and the problem is as follows


Tssue has to do with having a declarative security demand on a method that
is the implementation of an interface AND the type that implements the
interface is a value type

The problem has been fixed in whidbey. For now the workaround suggested is
to Convert the declarative demand to an imperative demand inside
GetObjectData().
Please let me know if you need any more information.

Thanks

Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
Back
Top