Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / March 2005

Tip: Looking for answers? Try searching our database.

Collection not getting serialized

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex Clark - 08 Mar 2005 22:20 GMT
Hi All,

I'm trying to force VS.NET to serialize items that have been added into a
collection.  This collection is a property of a complex type, which itself
is a property of another complex type which resides in a collection which is
a property of my component.

Essentially, VS.NET is not detecting the fact that I've added items into
this custom collection, and is not serializing the items to code.  After
much Google-trawling I've determined that I need to call the following two
lines of code:

Dim ics As IComponentChangeService =
DirectCast(GetService(GetType(IComponentChangeService)),
IComponentChangeService)
OnComponentChanging(Me, Nothing)

The problem is I don't know *where* specifically to do this.  I've tried
getting a reference to the IComponentChangeService in the constructor for my
Component, but even at design time it returns Null.  How do I get a hold of
this elusive object?  And once I do, where should I be calling
OnComponentChanging?

Many thanks,
Alex
joeycalisay - 09 Mar 2005 09:33 GMT
the snippet you have is usually used in designer classes.  do you have your
own collectioneditor (uitypeeditor)?

Signature

Joey Calisay
http://spaces.msn.com/members/joeycalisay/

> Hi All,
>
[quoted text clipped - 21 lines]
> Many thanks,
> Alex
Alex Clark - 09 Mar 2005 10:53 GMT
> the snippet you have is usually used in designer classes.  do you have
> your
> own collectioneditor (uitypeeditor)?

No, it's just using the default VS.NET CollectionEditor.  It's a really
strange situation, because all collection properties are marked with the
DesignerSerializationVisibility(Content), and I know that the types within
them can be serialized to code via my custom TypeConverter.  VS just won't
see any changes when I add to the collection, so I assumed this was the
issue.

Is there some way I can inherit from the default CollectionEditor and force
VS to use that as the designer for my collection class, and instruct it to
force an update of the code if something's added/removed?

Thanks,
Alex Clark

>> Hi All,
>>
[quoted text clipped - 26 lines]
>> Many thanks,
>> Alex
Nice Chap - 22 Mar 2005 12:23 GMT
VS.Net does not know the Add method of your collection ( it won't assume the
name !). So it can not serialise the contents of the colletion. You will
have to write your own collection serializer and add code to it.

Public Class UIWinCollectionSerializer

Inherits System.ComponentModel.Design.Serialization.CodeDomSerializer

etc etc...
joeycalisay - 28 Mar 2005 03:59 GMT
The CollectionCodeDomSerializer used by VS looks for the Add and AddRange
methods

Signature

Joey Calisay
http://spaces.msn.com/members/joeycalisay/

> VS.Net does not know the Add method of your collection ( it won't assume the
> name !). So it can not serialise the contents of the colletion. You will
[quoted text clipped - 5 lines]
>
> etc etc...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.