VB2012: I am trying to make a clone (not a copy) of the My.Settings class. I tried the DeepClone function found here on SO
Public Function DeepClone(Of T)(ByVal a As T) As T
Using stream As New System.IO.MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(stream, a)
stream.Position = 0
Return DirectCast(formatter.Deserialize(stream), T)
End Using
End Function
but it results in an exception
Type 'MyCompany.MyDept.TestApp.My.MySettings' in Assembly 'TestApp, Version=10.1.0.3, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Being the settings are a class and saved as XML there must be a way to clone them or am I just barking up the wrong tree?
~AGP