# Problem Serializing MsSql2008FeatureLayer after Upgrade to Desktop 5.0

**URL:** <https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740>\
**Category:** WinForms\
**Created:** [June 21, 2011, 3:14pm UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740 "2011-06-21T15:14:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven1](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/steven1/32/18983_2.png) [@Steven1](https://community.thinkgeo.com/u/Steven1)\
**Post date:** [June 21, 2011, 3:14pm UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740/1 "2011-06-21T15:14:09Z")

</div>

Hi,

As&nbsp;part&nbsp;of&nbsp;our&nbsp;project&nbsp;we&nbsp;try&nbsp;to&nbsp;save&nbsp;the&nbsp;layers&nbsp;that&nbsp;are&nbsp;open&nbsp;to&nbsp;disk&nbsp;so&nbsp;the&nbsp;map&nbsp;can&nbsp;be&nbsp;restored&nbsp;at&nbsp;a&nbsp;later&nbsp;time.&nbsp;After&nbsp;upgrading&nbsp;to&nbsp;MSD&nbsp;5.0&nbsp;we&nbsp;get&nbsp;an&nbsp;exception&nbsp;whenever&nbsp;we&nbsp;try&nbsp;to&nbsp;serialize&nbsp;a&nbsp;MsSqlServer2008FeatureLayer.&nbsp;Here&nbsp;is&nbsp;a&nbsp;code&nbsp;sample:

`' *****  Open a file stream to use for serializationoFormatter = New BinaryFormatter()oStream = New FileStream(sFileName, FileMode.Create, FileAccess.Write, FileShare.None)oOverlay = CType(WinformsMap1.Overlays(0), LayerOverlay)If oOverlay.Layers(0).IsOpen Then   oOverlay.Layers(0).Close()End IfoFormatter.Serialize(oStream, oOverlay.Layers(0))`

&nbsp;

Here&nbsp;is&nbsp;the&nbsp;exception:

System.Runtime.Serialization.SerializationException&nbsp;was&nbsp;unhandled  
  
&nbsp;&nbsp;Message=Type&nbsp;'System.Data.SqlClient.SqlConnection'&nbsp;in&nbsp;Assembly&nbsp;'System.Data,&nbsp;Version=4.0.0.0,&nbsp;Culture=neutral,&nbsp;PublicKeyToken=b77a5c561934e089'&nbsp;is&nbsp;not&nbsp;marked&nbsp;as&nbsp;serializable.  
  
&nbsp;&nbsp;Source=mscorlib  
  
&nbsp;&nbsp;StackTrace:  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType&nbsp;type)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type&nbsp;type,&nbsp;StreamingContext&nbsp;context)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object&nbsp;obj,&nbsp;ISurrogateSelector&nbsp;surrogateSelector,&nbsp;StreamingContext&nbsp;context,&nbsp;SerObjectInfoInit&nbsp;serObjectInfoInit,&nbsp;IFormatterConverter&nbsp;converter,&nbsp;ObjectWriter&nbsp;objectWriter,&nbsp;SerializationBinder&nbsp;binder)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo&nbsp;objectInfo,&nbsp;NameInfo&nbsp;memberNameInfo,&nbsp;NameInfo&nbsp;typeNameInfo)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object&nbsp;graph,&nbsp;Header[]&nbsp;inHeaders,&nbsp;\_\_BinaryWriter&nbsp;serWriter,&nbsp;Boolean&nbsp;fCheck)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream&nbsp;serializationStream,&nbsp;Object&nbsp;graph,&nbsp;Header[]&nbsp;headers,&nbsp;Boolean&nbsp;fCheck)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream&nbsp;serializationStream,&nbsp;Object&nbsp;graph)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;SerializeWMSLayer.Form1.SerializeWMSLayer()&nbsp;in&nbsp;C:\Users\steller\Documents\Visual&nbsp;Studio&nbsp;2010\Projects\ThinkGeo\SerializeSQLServerLayer\Form1.vb:line&nbsp;56  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;SerializeWMSLayer.Form1.btnSerialize\_Click(Object&nbsp;sender,&nbsp;EventArgs&nbsp;e)&nbsp;in&nbsp;C:\Users\steller\Documents\Visual&nbsp;Studio&nbsp;2010\Projects\ThinkGeo\SerializeSQLServerLayer\Form1.vb:line&nbsp;113  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Control.OnClick(EventArgs&nbsp;e)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Button.OnClick(EventArgs&nbsp;e)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Button.OnMouseUp(MouseEventArgs&nbsp;mevent)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Control.WmMouseUp(Message&&nbsp;m,&nbsp;MouseButtons&nbsp;button,&nbsp;Int32&nbsp;clicks)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Control.WndProc(Message&&nbsp;m)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.ButtonBase.WndProc(Message&&nbsp;m)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Button.WndProc(Message&&nbsp;m)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&&nbsp;m)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&&nbsp;m)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr&nbsp;hWnd,&nbsp;Int32&nbsp;msg,&nbsp;IntPtr&nbsp;wparam,&nbsp;IntPtr&nbsp;lparam)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&&nbsp;msg)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr&nbsp;dwComponentID,&nbsp;Int32&nbsp;reason,&nbsp;Int32&nbsp;pvLoopData)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32&nbsp;reason,&nbsp;ApplicationContext&nbsp;context)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32&nbsp;reason,&nbsp;ApplicationContext&nbsp;context)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]&nbsp;commandLine)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;SerializeWMSLayer.My.MyApplication.Main(String[]&nbsp;Args)&nbsp;in&nbsp;17d14f5c-a337-4978-8281-53493378c1071.vb:line&nbsp;81  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.AppDomain.\_nExecuteAssembly(RuntimeAssembly&nbsp;assembly,&nbsp;String[]&nbsp;args)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.AppDomain.ExecuteAssembly(String&nbsp;assemblyFile,&nbsp;Evidence&nbsp;assemblySecurity,&nbsp;String[]&nbsp;args)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.ThreadHelper.ThreadStart\_Context(Object&nbsp;state)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.ExecutionContext.Run(ExecutionContext&nbsp;executionContext,&nbsp;ContextCallback&nbsp;callback,&nbsp;Object&nbsp;state,&nbsp;Boolean&nbsp;ignoreSyncCtx)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.ExecutionContext.Run(ExecutionContext&nbsp;executionContext,&nbsp;ContextCallback&nbsp;callback,&nbsp;Object&nbsp;state)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.ThreadHelper.ThreadStart()  
  
&nbsp;&nbsp;InnerException:&nbsp;  
  
&nbsp;

Am&nbsp;I&nbsp;doing&nbsp;something&nbsp;wrong?

Thanks,

Steve

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 22, 2011, 12:12pm UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740/2 "2011-06-22T12:12:26Z")

</div>

Steven,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;posts!&nbsp;  
&nbsp;&nbsp;  
&nbsp;This&nbsp;problem&nbsp;is&nbsp;obvious&nbsp;bug&nbsp;in&nbsp;the&nbsp;5.0,&nbsp;I&nbsp;have&nbsp;posted&nbsp;it&nbsp;to&nbsp;our&nbsp;development&nbsp;team&nbsp;and&nbsp;if&nbsp;there&nbsp;are&nbsp;any&nbsp;updates&nbsp;I&nbsp;will&nbsp;let&nbsp;you&nbsp;know,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Scott,

---

<div class="post-metadata">

**Author:** ![Steven1](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/steven1/32/18983_2.png) [@Steven1](https://community.thinkgeo.com/u/Steven1)\
**Post date:** [June 22, 2011, 1:05pm UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740/3 "2011-06-22T13:05:19Z")

</div>

Scott,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;the&nbsp;quick&nbsp;response!&nbsp;I’ll&nbsp;stand&nbsp;by&nbsp;for&nbsp;a&nbsp;fix&nbsp;in&nbsp;an&nbsp;upcoming&nbsp;daily&nbsp;build.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 22, 2011, 1:29pm UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740/4 "2011-06-22T13:29:38Z")

</div>

Steven,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;for&nbsp;the&nbsp;inconvenience,&nbsp;just&nbsp;wait&nbsp;for&nbsp;a&nbsp;little&nbsp;times&nbsp;for&nbsp;this&nbsp;bug&nbsp;fix,&nbsp;I&nbsp;will&nbsp;let&nbsp;you&nbsp;know&nbsp;which&nbsp;DailyBuild&nbsp;version&nbsp;you&nbsp;should&nbsp;get,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Scott,

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 23, 2011, 12:03pm UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740/5 "2011-06-23T12:03:43Z")

</div>

Steven,&nbsp;  
&nbsp;&nbsp;  
&nbsp;This&nbsp;bug&nbsp;had&nbsp;been&nbsp;fixed.&nbsp;Please&nbsp;get&nbsp;the&nbsp;latest&nbsp;daily&nbsp;build&nbsp;(5.0.41.0&nbsp;or&nbsp;later)&nbsp;to&nbsp;have&nbsp;another&nbsp;try.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Scott,

---

<div class="post-metadata">

**Author:** ![Steven1](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/steven1/32/18983_2.png) [@Steven1](https://community.thinkgeo.com/u/Steven1)\
**Post date:** [June 24, 2011, 11:00am UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740/6 "2011-06-24T11:00:19Z")

</div>

Scott,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks!&nbsp;Working&nbsp;fine&nbsp;now.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 24, 2011, 1:46pm UTC](https://community.thinkgeo.com/t/problem-serializing-mssql2008featurelayer-after-upgrade-to-desktop-5-0/1740/7 "2011-06-24T13:46:18Z")

</div>

Steven,&nbsp;  
&nbsp;&nbsp;  
&nbsp;You&nbsp;are&nbsp;welcome,&nbsp;any&nbsp;more&nbsp;questions&nbsp;please&nbsp;let&nbsp;me&nbsp;know&nbsp;again,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Scott,
