# XML Serializer

**URL:** https://tech-community.robotics.abb.com/t/xml-serializer/1038
**Category:** Developer Tools
**Created:** [February 27, 2007, 3:10pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038 "2007-02-27T15:10:29Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![oscar\_f](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@oscar\_f](https://tech-community.robotics.abb.com/u/oscar_f)
#### Post date: [February 27, 2007, 3:10pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/1 "2007-02-27T15:10:29Z")

</div>

Hello,

I’m trying to use the xmlSerializer to serialize my data.

Here there is an example that works correcly in a windonws form based application, but not in the FP application:

Public Class MyDataClass

Inherits System.Object

Public Program\_Name As String = “prg\_Name”

Public program\_numData As Double = 0

Public Function Save(ByVal XMLPath As String, ByRef mydata As BWProgramData) As Boolean

Try

Dim writer As TextWriter = New StreamWriter(XMLPath)

Dim ser As New XmlSerializer(mydata.GetType)

ser.Serialize(writer, mydata)

writer.Close()

Return True

Catch ex As Exception

Return False

End Try

End Function

What it si wrong?

Can you suggest alternative approach?

BR

Oscar

---

<div class="post-metadata">

### Author: ![oscar\_f](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@oscar\_f](https://tech-community.robotics.abb.com/u/oscar_f)
#### Post date: [February 27, 2007, 3:11pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/2 "2007-02-27T15:11:03Z")

</div>

PS: I’m using RAB 5.08

O.

---

<div class="post-metadata">

### Author: ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)
#### Post date: [February 27, 2007, 4:50pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/3 "2007-02-27T16:50:14Z")

</div>

Hi Oscar  
Make sure that you aren’t using any classes that aren’t supported by .NET compact framework which is used by FP.

---

<div class="post-metadata">

### Author: ![RussD](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@RussD](https://tech-community.robotics.abb.com/u/RussD)
#### Post date: [February 27, 2007, 6:21pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/4 "2007-02-27T18:21:09Z")

</div>

Can you be more specific about what the error is and/or how it is failing?

There are two new pieces of functionality in 5.08 that make this easier: writing debug or trace messages to the robot console and remote device debugging.

Write Debug messages to console:

1. Use the Imports (VB) or Using (C#) to access the ABB.Robotics.Diagnostics namespace.

2. Add debug messages in your code such as Debug.WriteLine(“debug message1”) or Trace.Writeline(“Trace message 1”)

3. Build and deploy your application, restart FlexPendant.

4. In the console, turn on FlexPendant debug message printing by entering “fpcmd\_enable\_console\_output 3” (no quotes)

5. Observe the console output for troubleshooting information.

6. Disable debug output by entering “fpcmd\_disable\_console\_output” (no quotes)

Remote device debugging:

With the proper hardware setup, you can use the VS2005 remote debugger to attach to the Taf process, i.e the FlexPendant application itself. When you do this, you can set breakpoints and step through your code to see exactly where it is failing.

The procedure for performing this type of debugging is described in the product documentation that is supplied with the release version of RAB 5.08.

---

<div class="post-metadata">

### Author: ![oscar\_f](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@oscar\_f](https://tech-community.robotics.abb.com/u/oscar_f)
#### Post date: [February 28, 2007, 2:11pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/5 "2007-02-28T14:11:23Z")

</div>

Hi,

**according to the info in msdn, the XMLSerializer is supported in .NET compact framework 2.0:**

[http://msdn2.microsoft.com/en-us/library/system.xml.serializ ation.xmlserializer.aspx](http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx)

**This is the exception error:**

System.InvalidOperationException was caught  
Message=“There was an error generating the XML document.”  
Source=“System.Xml”  
StackTrace:  
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)  
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o)  
at TpsViewBendwareOnBoard.BWProgramData.Save(String XMLPath, BWProgramData& mydata)

this log does not say too much too me..

PS I’m testing it on virtual IRC5

Thanks

Oscar

---

<div class="post-metadata">

### Author: ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)
#### Post date: [February 28, 2007, 2:25pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/6 "2007-02-28T14:25:14Z")

</div>

Hi Oscar  
Sounds to me that there is a problem with the file path in some way.

---

<div class="post-metadata">

### Author: ![ReneK](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/renek/32/3229_2.png) [@ReneK](https://tech-community.robotics.abb.com/u/ReneK)
#### Post date: [March 1, 2007, 12:11pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/7 "2007-03-01T12:11:58Z")

</div>

Hello,

try to put your TpsView…dll additionaly in the vc bin folder of the mediapool you are using. Worked for me in 5.07 (not tested with 5.08 though).

On a real controller you should be fine…

best regards

Ren?

---

<div class="post-metadata">

### Author: ![RussD](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@RussD](https://tech-community.robotics.abb.com/u/RussD)
#### Post date: [March 1, 2007, 1:03pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/8 "2007-03-01T13:03:47Z")

</div>

Try using the Temp directory on the FlexPendant (which corresponds to LocalDirectory) as the destination where the file will be created, then use FileSystem.PutFile to copy it to the flashdisk after the file is created.

---

<div class="post-metadata">

### Author: ![oscar\_f](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@oscar\_f](https://tech-community.robotics.abb.com/u/oscar_f)
#### Post date: [March 1, 2007, 3:23pm UTC](https://tech-community.robotics.abb.com/t/xml-serializer/1038/9 "2007-03-01T15:23:18Z")

</div>

Hello again ,

**the suggestion from Renek works**.

I copied my tpsApp in the mediapool.

Oscar
