Using with VB.net

Topics: Developer Forum, User Forum
Apr 23, 2007 at 8:31 AM
In my new project i added our collection, but i have a problem when use in vb project. My solution throw an exception :
Eccezione first-chance di tipo 'System.Runtime.Serialization.SerializationException' in mscorlib.dll
"System.Runtime.Serialization.SerializationException: Impossibile ottenere il membro 'CollectedItem_PropertyChanged'.
in System.Reflection.MemberInfoSerializationHolder.GetRealObject(StreamingContext context)
in System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder) ......" what is the problem ?, I have not correct set the serialization ?
The 2nd question is, for adding item from my NHibernate dal its correct use this code:

<Serializable()> Public Class AnagraficaCollection
Inherits RafCollection(Of Anagrafica)
Private _Lista As IList(Of Anagrafica)
Public Property InternalList() As IList(Of Anagrafica)
Get
Return _Lista
End Get
Set(ByVal value As IList(Of Anagrafica))
_Lista = value
For h As Integer = 0 To _Lista.Count - 1
MyBase.Add(_Lista(h))
Next
End Set
End Property
End Class

Thanks Stefano
Coordinator
May 2, 2007 at 9:30 PM
I cust&paste the same answer I gave you on the newsgroups:

Did you specified to not serialize the entity?
In C# (as in the project example) you have to do tihis way:
field: NonSerialized
public event PropertyChangedEventHandler PropertyChanged;

In vb.net there is not a field correspondence. The solution is to expand the event:

<Serializable()> _
Public Class Something
Implements INotifyPropertyChanged

#Region "Sostituto di ==> Event PropertyChanged As
PropertyChangedEventHandler"
<NonSerialized()> _
Private PropertyChangedHandlers As New Generic.List(Of
PropertyChangedEventHandler)

Public Custom Event PropertyChanged As PropertyChangedEventHandler
Implements INotifyPropertyChanged.PropertyChanged
AddHandler(ByVal value As PropertyChangedEventHandler)
If PropertyChangedHandlers Is Nothing Then
PropertyChangedHandlers = New Generic.List(Of PropertyChangedEventHandler)()
PropertyChangedHandlers.Add(value)
End AddHandler

RemoveHandler(ByVal value As PropertyChangedEventHandler)
PropertyChangedHandlers.Remove(value)
End RemoveHandler

RaiseEvent(ByVal sender As Object, ByVal e As
PropertyChangedEventArgs)
For Each Element As PropertyChangedEventHandler In
PropertyChangedHandlers
Element.Invoke(sender, e)
Next
End RaiseEvent
End Event
#End Region
End Class

May 7, 2007 at 8:10 AM
Hi Raf,
i modified my code but don't work, throw this exception (complete description string):
System.Runtime.Serialization.SerializationException: Impossibile ottenere il membro 'CollectedItem_PropertyChanged'.
in
System.Reflection.MemberInfoSerializationHolder.GetRealObject(StreamingCont­ext context)
in
System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHol­der holder)
in System.Runtime.Serialization.ObjectManager.DoFixups()
in
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(Hea­derHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
in
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(­Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
in
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(­Stream serializationStream)
in Vevy.Collections.EntityHelper.SerializeClone(Object o) in D:
\LibrerieSupporto\RafCollection-12314\RafCollection
\RafCollectionSolution\RafCollection\EntityHelper.cs:riga 40
Eccezione first-chance di tipo
'System.Runtime.Serialization.SerializationException' in
RafCollection.dll

I have uploaded a test project http://www.ciessea.it/testrafcollection.rar, you can look what are the problem ?
Many thanks
Stefano
May 21, 2007 at 1:25 PM
To resolve the problem

mark _PropertyChanged in Storage.cs line 242. with NonSerialized

May 21, 2007 at 2:44 PM
Giuseppe, work fine

Thanks a lot
Stefano