Code Serialization problems

A

Alex Clark

Hi all,

Apologies for the cross-post but I can't determine if this is a VS .NET
problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA,
VB.NET.

I'm coding a custom component which is designed to be dropped onto a form
and have it's properties manipulated at runtime. I have a custom
implementation of the TypeConverter class called UniversalTypeConverter
which inherits from ExpandableObjectConverter, and for the most part this is
serializing my properties to code without problem, except for a minor quirk.

In simple terms, my Class hierarchy is as follows:

MyComponent
|_ Collection (Strongly Typed Implementation of Class A)
|_ Item (Class A)
|_ Read/Write Property (Class B)
|_ Collection (Strongly Typed Implementation of Class C)

My problem is that with the class hierarchy layed out as above, VS does NOT
serialize the items in the collection of Class C (collection is a property
of Class B) to my code. I can add them using the property editor in VS no
problem, but when I go back to the collection, it's empty (this happens even
if I don't rebuild/save the project in between). Class A, Class B, and
Class C are all attributed with my UniversalTypeConverter, which is geared
up to handle each of them.

I know this sounds like I'm doing something wrong with my TypeConverter, but
I've tested it separately on each of these classes and it works fine. For
example, when I add a test property to my component as below....

MyComponent
|_ Test Property (Class A) {tested as ReadOnly and Read/Write}
|_ Read/Write Property (Class B)
|_ Collection (Strongly Typed Implementation of Class C)

....and I add items to the Class C collection on the above test property, VS
works perfectly. Equally, I had to set it up as follows as a workaround,
which works perfectly...

MyComponent
|_ Collection (Strongly Typed Implementation of Class A)
|_ Item (Class A)
|_ Collection (Strongly Typed Implementation of Class C) -->
Points to Class A's private variable of type Class B

So essentially, in Class A, instead of...

Public Property MyClassB As ClassB
....get/set...
End Property
(doesn't work)

I have the following...

Public Readonly Property MyClassCs
Get
Returns m_MyClassB.MyClassCCollection
End Get
End Property

Which works fine with VS, it's able to serialize the items in the collection
no problem.

Let me clear up the obvious: DesignerSerializationVisibility(Content) has
been attributed to properties where applicable. I've tried my TypeConverter
with constructors that both are and are not full descriptors of the object
instance, I've tried removing properties and restructuring them in my Class
C, but none of it has had any effect.

I've even attached another instance of VS to the first in order to debug it
and step through the code generation. It correctly identifies items in the
collection when it comes to serialize it out to code. It just doesn't seem
to want to do it. No exceptions are thrown (I had it trapping all .NET
exceptions, even those that were handled).

So my question is, is there some limit as to the "depth" that VS's code
generator can go when serializing component properties to code? I've just
proven to myself that the only way my component can work is to make the
collection property one step "shallower", ie move it up a level in my class
hierarchy. Then VS generates the code flawlessly.

Can someone from MS please confirm/deny this?

Many thanks,

Alex Clark
 
P

Peter Huang [MSFT]

Hi

I reviewed the thread and find that there is a similar issue in the
newsgroup below.And we will reply to you in that queue.
Subject: Code Serialization problems
Newsgroups: microsoft.public.vsnet.general

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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