473,473 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Add <NonSerialized()> attribute to implicitly created xxxEvent private fields??


Is there a way to add the NonSerialized attribute to the "Event"
fields that the VB.NET compiler creates when you declare an event?

I have a class that we use with binary serialization and we just added
two events so now old files won't deserialize to the new class. It
says it was expecting 2 more fields, obviously corresponding to the
two private fields created for the events.

I tried adding the fields explicitly with the NonSerialized attribute
but then I get a compiler error about the names conflicting.

Thanks,

Sam

Nov 21 '05 #1
5 1811
Hi

Based on my understanding, you wants to mark a event in VB.NET as
NonSerialized.
In C# 1.1 we have an attribute [field:NonSerialized].
Unfortunately this is not supported in VB.NET on .net framework 1.1 and it
will be added in vb.net 2005.
Here is a link for your reference.

..NET 2.0 solution to serialization of objects that raise events
http://www.lhotka.net/WeBlog/PermaLi...-4845-b649-e0d
840e6de2c

Best regards,

Perter Huang
Microsoft Online Partner Support

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

Nov 21 '05 #2

That's a lot of code to fix a simple problem--the C# solution is fine
for most cases and certainly would be good as an option in VB.NET.
The proposed solution replaces a single attribute with ~13 lines of
code (assuming the custom functions just marshal the calls to a
declared non-serializable delegate).

Best regards,

Sam
On Thu, 03 Feb 2005 08:54:36 GMT, v-******@online.microsoft.com
("Peter Huang" [MSFT]) wrote:
Hi

Based on my understanding, you wants to mark a event in VB.NET as
NonSerialized.
In C# 1.1 we have an attribute [field:NonSerialized].
Unfortunately this is not supported in VB.NET on .net framework 1.1 and it
will be added in vb.net 2005.
Here is a link for your reference.

NET 2.0 solution to serialization of objects that raise events
http://www.lhotka.net/WeBlog/PermaLi...-4845-b649-e0d
840e6de2c

Best regards,

Perter Huang
Microsoft Online Partner Support

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


Nov 21 '05 #3
Peter,
In C# 1.1 we have an attribute [field:NonSerialized].
... it
will be added in vb.net 2005. Are you certain it will be added, Lhotka's sample does not show:

<Field: NonSerialized> _
Public Event NameChanged As EventHander

Which is what most if not all of my serialization code needs, rarely do I
need Custom Events that Rocky shows, where some of the handlers are
serialized & some are not.

I have classes that have multiple events, these classes are serialzed to
files using Binary Serialization. The event handlers do not need to be
serialized with the file, using <Field: NonSerialized> would save 12+ lines
of code per event, which would reduce a significant amount of duplicate
code!

Also the above would solve *all* the questions I've seen on events being
serialized in the newsgroups.

VB.NET 2005 really needs both flavors, just as C# 1.0 supported both flavors
([field:NonSerialized] & custom events).

In other words, as Samuel suggests the custom event is an excessive amount
of code for what is a simply problem in most cases...

Hope this helps
Jay

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:b2**************@cpmsftngxa10.phx.gbl... Hi

Based on my understanding, you wants to mark a event in VB.NET as
NonSerialized.
In C# 1.1 we have an attribute [field:NonSerialized].
Unfortunately this is not supported in VB.NET on .net framework 1.1 and it
will be added in vb.net 2005.
Here is a link for your reference.

NET 2.0 solution to serialization of objects that raise events
http://www.lhotka.net/WeBlog/PermaLi...-4845-b649-e0d
840e6de2c

Best regards,

Perter Huang
Microsoft Online Partner Support

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

Nov 21 '05 #4
Hi Jay,

Thanks for your feedback.
And I am sorry if I have made any mistake, in our internal document, we are
planning to add the feature in vb 2005, since the whidbey is not released
so far, so I can not guarantee if the feature will occur in the release
version.

Hope this helps.

Best regards,

Perter Huang
Microsoft Online Partner Support

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

Nov 21 '05 #5
Hi Sam,

Thanks for your feedback.
We will try to keep improving our product to make VB.NET a more powerful
dev tool.

Best regards,

Perter Huang
Microsoft Online Partner Support

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

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ehsan | last post by:
Does this attribute really work? I'm trying to "deep" serialize one of my objects which has a member variable pointing to a Form object. I don't want to serialize this form (and I know that I...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.