473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

PropertyChanged Property in Proxy Class Generated by VS 2008 or SayThat Five Times Fast

We have created a object library that implements the
INotifyPropertyChanged.PropertyChanged to bubble changes up to higher
level classes. For instance, we have a person class that can have
relationships with other persons. If there is a change in the
relationship (i.e. status, type etc) then we want the PropertyChanged
event to fire and notify the top level Person object of that change.
The PropertyChanged event is implemented as follows:

Public Event PropertyChanged As PropertyChangedEventHandler Implements
INotifyPropertyChanged.PropertyChanged
I don't think you need the specific delegate handler to get the
picture (let me know if you do). Either way, I am now trying to use
the classes in a silverlight application that uses WCF. When I add the
ServiceReference to the silverlight project, the utility generates the
proxy classes for me and generates the following Property:
<System.Runtime.Serialization.DataMemberAttribute( IsRequired:=True)_
Public Property PropertyChangedEvent() As
System.ComponentModel.PropertyChangedEventHandler
Get
Return Me.PropertyChangedEventField
End Get
Set(ByVal value As
System.ComponentModel.PropertyChangedEventHandler)
If
(Object.ReferenceEquals(Me.PropertyChangedEventFie ld, Value) <True)
Then
Me.PropertyChangedEventField = Value
Me.RaisePropertyChanged("PropertyChangedEvent")
End If
End Set
End Property

The compiler then throws the following error:

property 'PropertyChangedEvent' conflicts with a member implicitly
declared for event 'PropertyChanged' in class 'ModelBaseClass'.

I am assuming the issue is because I have implemented the
INotifyChange.PropertyChangedEventHandler and the proxy class
generated uses the System.ComponentModel.PropertyChangedEventHandler,
but I am unsure what I should do to correct this issue as I don't have
control over the proxy class generation. The ObjectModel is compiled
under .Net 2.0 and the WCF project is using 3.5 and I am wondering if
this is could also affect the situation.

Any clarification would be greatly appreciated.

Sincerely,

D
Oct 1 '08 #1
2 7155
On Oct 1, 1:39*pm, Dinsdale <russ.ha...@gmail.comwrote:
We have created a object library that implements the
INotifyPropertyChanged.PropertyChanged to bubble changes up to higher
level classes. For instance, we have a person class that can have
relationships with other persons. If there is a change in the
relationship (i.e. status, type etc) then we want the PropertyChanged
event to fire and notify the top level Person object of that change.
The PropertyChanged event is implemented as follows:

Public Event PropertyChanged As PropertyChangedEventHandler Implements
INotifyPropertyChanged.PropertyChanged

I don't think you need the specific delegate handler to get the
picture (let me know if you do). Either way, I am now trying to use
the classes in a silverlight application that uses WCF. When I add the
ServiceReference to the silverlight project, the utility generates the
proxy classes for me and generates the following Property:

<System.Runtime.Serialization.DataMemberAttribute( IsRequired:=True)_
* * * * Public Property PropertyChangedEvent() As
System.ComponentModel.PropertyChangedEventHandler
* * * * * * Get
* * * * * * * * Return Me.PropertyChangedEventField
* * * * * * End Get
* * * * * * Set(ByVal value As
System.ComponentModel.PropertyChangedEventHandler)
* * * * * * * * If
(Object.ReferenceEquals(Me.PropertyChangedEventFie ld, Value) <True)
Then
* * * * * * * * * * Me.PropertyChangedEventField = Value
* * * * * * * * * * Me.RaisePropertyChanged("PropertyChangedEvent")
* * * * * * * * End If
* * * * * * End Set
* * * * End Property

The compiler then throws the following error:

property 'PropertyChangedEvent' conflicts with a member implicitly
declared for event 'PropertyChanged' in class 'ModelBaseClass'.

I am assuming the issue is because I have implemented the
INotifyChange.PropertyChangedEventHandler and the proxy class
generated uses the System.ComponentModel.PropertyChangedEventHandler,
but I am unsure what I should do to correct this issue as I don't have
control over the proxy class generation. The ObjectModel is compiled
under .Net 2.0 and the WCF project is using 3.5 and I am wondering if
this is could also affect the situation.

Any clarification would be greatly appreciated.

Sincerely,

D

Okay, I finally found the cause of this particular error. The
following link explains that "The Visual Basic compiler creates
implicit members corresponding to certain programming elements you
declare." Because I called my event PropertyChanged, and there is an
implicit member created called PropertyChangedEvent already created by
VB, when the AddService wizard generated the proxy class and named the
proxy property PropertyChangedEvent, there was a name collision. I
wonder if this would be an issue in C#? The link explaining the issue
is http://msdn.microsoft.com/en-us/library/ms184639.aspx. Once I
changed the event name to ObjectPropertyChanged, everything compiled

Anyway, I'm getting an abstract 404 error now so I decided to create a
really simple test class to move forward. The class is as follows:

<Serializable()_
Public Class SimpleClass

Private _firstName As String
Private _lastName As String
Private _birthDate As Date

Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal value As String)
_firstName = value
End Set
End Property

Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal value As String)
_lastName = value
End Set
End Property

Public Property BirthDate() As Date
Get
Return _birthDate
End Get
Set(ByVal value As Date)
_birthDate = value
End Set
End Property

End Class
This worked fine, so I added the INotifyChanged interface to my class:

Imports System.ComponentModel

<Serializable()_
Public Class SimpleClass
Implements INotifyPropertyChanged

Public Event ObjectPropertyChanged As PropertyChangedEventHandler
Implements INotifyPropertyChanged.PropertyChanged
....

Now I am getting the following exception:

Exception:
There was an error while trying to deserialize parameter
http://tempuri.org/:GetSimpleClassResult. Please see InnerException
for more details.

Inner Exception:
Type 'System.ComponentModel.PropertyChangedEventHandler ' cannot be
serialized. Consider marking it with the DataContractAttribute
attribute, and marking all of its members you want serialized with the
DataMemberAttribute attribute.

I'm reading through a WCF book as fast as I can, but there doesn't
seem to be anything about INotifyPropertyChanged issues in there. Once
again, I would really appreciate any clarification on this from some
of you MS gurus so I can get back at creating a proof of concept. This
is starting to look really bad and I'm going to have trouble
convincing my boss that that we should switch to Silverlight and WCF
if I don't get something working soon! (Please don't read that as
blame on the technology, it's just a fact that I've struggled to get
this running).

Cheers,

D
Oct 2 '08 #2
On Oct 2, 1:49*pm, Dinsdale <russ.ha...@gmail.comwrote:
On Oct 1, 1:39*pm, Dinsdale <russ.ha...@gmail.comwrote:
We have created a object library that implements the
INotifyPropertyChanged.PropertyChanged to bubble changes up to higher
level classes. For instance, we have a person class that can have
relationships with other persons. If there is a change in the
relationship (i.e. status, type etc) then we want the PropertyChanged
event to fire and notify the top level Person object of that change.
The PropertyChanged event is implemented as follows:
Public Event PropertyChanged As PropertyChangedEventHandler Implements
INotifyPropertyChanged.PropertyChanged
I don't think you need the specific delegate handler to get the
picture (let me know if you do). Either way, I am now trying to use
the classes in a silverlight application that uses WCF. When I add the
ServiceReference to the silverlight project, the utility generates the
proxy classes for me and generates the following Property:
<System.Runtime.Serialization.DataMemberAttribute( IsRequired:=True)_
* * * * Public Property PropertyChangedEvent() As
System.ComponentModel.PropertyChangedEventHandler
* * * * * * Get
* * * * * * * * Return Me.PropertyChangedEventField
* * * * * * End Get
* * * * * * Set(ByVal value As
System.ComponentModel.PropertyChangedEventHandler)
* * * * * * * * If
(Object.ReferenceEquals(Me.PropertyChangedEventFie ld, Value) <True)
Then
* * * * * * * * * * Me.PropertyChangedEventField = Value
* * * * * * * * * * Me.RaisePropertyChanged("PropertyChangedEvent")
* * * * * * * * End If
* * * * * * End Set
* * * * End Property
The compiler then throws the following error:
property 'PropertyChangedEvent' conflicts with a member implicitly
declared for event 'PropertyChanged' in class 'ModelBaseClass'.
I am assuming the issue is because I have implemented the
INotifyChange.PropertyChangedEventHandler and the proxy class
generated uses the System.ComponentModel.PropertyChangedEventHandler,
but I am unsure what I should do to correct this issue as I don't have
control over the proxy class generation. The ObjectModel is compiled
under .Net 2.0 and the WCF project is using 3.5 and I am wondering if
this is could also affect the situation.
Any clarification would be greatly appreciated.
Sincerely,
D

Okay, I finally found the cause of this particular error. The
following link explains that "The Visual Basic compiler creates
implicit members corresponding to certain programming elements you
declare." Because I called my event PropertyChanged, and there is an
implicit member created called PropertyChangedEvent already created by
VB, when the AddService wizard generated the proxy class and named the
proxy property PropertyChangedEvent, there was a name collision. I
wonder if this would be an issue in C#? The link explaining the issue
ishttp://msdn.microsoft.com/en-us/library/ms184639.aspx. Once I
changed the event name to ObjectPropertyChanged, everything compiled

Anyway, I'm getting an abstract 404 error now so I decided to create a
really simple test class to move forward. The class is as follows:

<Serializable()_
Public Class SimpleClass

* * Private _firstName As String
* * Private _lastName As String
* * Private _birthDate As Date

* * Public Property FirstName() As String
* * * * Get
* * * * * * Return _firstName
* * * * End Get
* * * * Set(ByVal value As String)
* * * * * * _firstName = value
* * * * End Set
* * End Property

* * Public Property LastName() As String
* * * * Get
* * * * * * Return _lastName
* * * * End Get
* * * * Set(ByVal value As String)
* * * * * * _lastName = value
* * * * End Set
* * End Property

* * Public Property BirthDate() As Date
* * * * Get
* * * * * * Return _birthDate
* * * * End Get
* * * * Set(ByVal value As Date)
* * * * * * _birthDate = value
* * * * End Set
* * End Property

End Class

This worked fine, so I added the INotifyChanged interface to my class:

Imports System.ComponentModel

<Serializable()_
Public Class SimpleClass
* * Implements INotifyPropertyChanged

Public Event ObjectPropertyChanged As PropertyChangedEventHandler
Implements INotifyPropertyChanged.PropertyChanged
...

Now I am getting the following exception:

Exception:
There was an error while trying to deserialize parameterhttp://tempuri.org/:GetSimpleClassResult. *Please see InnerException
for more details.

Inner Exception:
Type 'System.ComponentModel.PropertyChangedEventHandler ' cannot be
serialized. Consider marking it with the DataContractAttribute
attribute, and marking all of its members you want serialized with the
DataMemberAttribute attribute.

I'm reading through a WCF book as fast as I can, but there doesn't
seem to be anything about INotifyPropertyChanged issues in there. Once
again, I would really appreciate any clarification on this from some
of you MS gurus so I can get back at creating a proof of concept. This
is starting to look really bad and I'm going to have trouble
convincing my boss that that we should switch to Silverlight and WCF
if I don't get something working soon! (Please don't read that as
blame on the technology, it's just a fact that I've struggled to get
this running).

Cheers,

D
Oh, forgot to mention that the compiler won't let me add the
DataMember attribute to the event...

Cheers,

D
Oct 2 '08 #3

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

Similar topics

5
by: Benne Smith | last post by:
Hi, I have three enviroments; a development, a testing and a production enviroment. I'm making a big application (.exe), which uses alot of different webservices. I don't use the webservices...
3
by: John Baro | last post by:
I need to implement an event to notify when a property has changed. Method 1. If I use a generic PropertyChanged event from System.ComponentModel then it will be raised for every property if 1...
8
by: Joe | last post by:
I have a web service which returns many types (classes) to match the return type. I want to cast the return type to the actual class type. For example: namespace Test { class MyClass { ...
3
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three...
5
by: HenrySeque | last post by:
I have a webservice and I add a web reference from my web project. I want the proxy class to implements an Interface, but I didn't find the source code of the proxy class and I don't want to...
5
by: Mark | last post by:
Hi. I searched for hours now but can't find how to get the following to work: A usercontrol with two properties (A and B). If A is changed in the designer, B should be changed as well. This...
4
by: Fabio | last post by:
An ASP.NET 2.0 web site contains a web form and a web service. The web form consumes the web service. There is a Book class in the App_Code folder. The web service exposes a method that returns a...
2
by: Jon Miller | last post by:
Hi, I created a web service using Java/JAX-WS. I'm able to consume this web service using VS 2005 and .NET without a problem. However, the class and property names that were generated for the...
1
by: Arpan | last post by:
A class file named "SecureDBWS.vb" exsting in C:\Inetpub\wwwroot\ASPX\Business folder has the following code: Imports System Imports System.Data Imports System.Data.SqlClient Imports...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.