![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | TypeDescriptorProvider limited in actual implementation? Hello everyone, I've been fooling around with what's possible and not with the TypeDescriptorProvider and found a limitation that I would like confirmed if possible. I derived a class from CustomTypeDescriptor and did an override on the GetAttributes method and added a Serializeable attribute; this way any type registered with my TypeDescriptorProvider would supposedly be marked as Serializeable without having to actually modify that class's code. However, when I tried to serialize it with a BinaryFormatter I found that I get the usual "not marked Serializeable" exception. I believe that this is due to the formatter using reflection rather than the TypeDescriptor in order to get the attributes. Am I correct in my assumption and if so, then how useful is the TypeDescriptor system? Regards, Anthony |
My System Specs![]() |
| | #2 (permalink) |
| | Re: TypeDescriptorProvider limited in actual implementation? Serializable is a "special" attribute, kinda like MethodImpl. It has meaning to the compiler, but not the CLR. In fact if you look in Reflector you'll see that serializable types don't even have the attribute in their metadata. Instead it's a core property of the type itself. Type.IsSerializable tells you if a type is serializable or not, but you can't really change that fact at runtime. You could, on the other hand, build a dynamic serializable type at runtime and copy the members in. Josh Einstein "Anthony Paul" <anthonypaulo@xxxxxx> wrote in message news:f1f64617-0777-43aa-969f-83b9300aabc7@xxxxxx Quote: > Hello everyone, > > I've been fooling around with what's possible and not with the > TypeDescriptorProvider and found a limitation that I would like > confirmed if possible. I derived a class from CustomTypeDescriptor > and > did an override on the GetAttributes method and added a > Serializeable > attribute; this way any type registered with my > TypeDescriptorProvider > would supposedly be marked as Serializeable without having to > actually > modify that class's code. However, when I tried to serialize it with > a > BinaryFormatter I found that I get the usual "not marked > Serializeable" exception. I believe that this is due to the formatter > using reflection rather than the TypeDescriptor in order to get the > attributes. Am I correct in my assumption and if so, then how useful > is the TypeDescriptor system? > > Regards, > > Anthony |
My System Specs![]() |
| | #3 (permalink) |
| | Re: TypeDescriptorProvider limited in actual implementation? Ahhh, then that explains it... it is, in fact, a pseudo custom attribute, quite different from a normal attribute. Thank you Josh. Regards, Anthony On Dec 24, 3:19*am, "Josh Einstein" <josheinst...@xxxxxx> wrote: Quote: > Serializable is a "special" attribute, kinda like MethodImpl. It has meaning > to the compiler, but not the CLR. In fact if you look in Reflector you'll > see that serializable types don't even have the attribute in their metadata. > Instead it's a core property of the type itself. > > Type.IsSerializable tells you if a type is serializable or not, but you > can't really change that fact at runtime. You could, on the other hand, > build a dynamic serializable type at runtime and copy the members in. > > Josh Einstein > > "Anthony Paul" <anthonypa...@xxxxxx> wrote in message > > news:f1f64617-0777-43aa-969f-83b9300aabc7@xxxxxx > Quote: > > Hello everyone, Quote: > > I've been fooling around with what's possible and not with the > > TypeDescriptorProvider and found a limitation that I would like > > confirmed if possible. I derived a class from CustomTypeDescriptor > > and > > did an override on the GetAttributes method *and added a > > Serializeable > > attribute; this way any type registered with my > > TypeDescriptorProvider > > would supposedly be marked as Serializeable without having to > > actually > > modify that class's code. However, when I tried to serialize it with > > a > > BinaryFormatter I found that I get the usual "not marked > > Serializeable" exception. I believe that this is due to the formatter > > using reflection rather than the TypeDescriptor in order to get the > > attributes. Am I correct in my assumption and if so, then how useful > > is the TypeDescriptor system? Quote: > > Regards, Quote: > > Anthony |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Class implementation help please | VB Script | |||
| AHCI Implementation | Vista General | |||
| MOM.Implementation Error | Vista performance & maintenance | |||
| UAC - practical implementation? | Vista security | |||