Singleton Pattern & Serialization

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

How would I make a class implementing a Singleton Pattern serializable.
My problem is the Singleton Pattern 'requires' the constructor to be Private
and serialization requires the constructor to be Public.

Thanks,

Michael
 
You can make the constructor protected:
Imports System.Runtime.Serialization

....

Protected Sub New(ByVal info As SerializationInfo, ByVal context As
StreamingContext)
MyBase.New(info, context)
End Sub




Shariq
(e-mail address removed)
 
Of course,

how silly of me not to think about that!

Thanks a 1.000 times Shariq.

Kind regards,

Michael
 
Hi Jay,

Thanks for the links.
I am indeed still facing issues re the Scope of the Constructor.
I think me problem lies in the fact that the Classes Inherit from a
Base-Class and use an XmlSerializer.

I'm going to try out the approach of the article (today).

Thanks,

Michael
 
Back
Top