• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

problem deserialising an xml file

I have the following:
Private Function ConvertXMLToBDC(ByVal xmlPathFile As String) As BdcHandoffFile        
        Dim tmpBDC As New BdcHandoffFile
        Dim deSerialiser As XmlSerializer
        Dim xmlReader As New XmlTextReader(xmlPathFile)

        deSerialiser = New XmlSerializer(typeof(tmpBDC))        

        tmpBDC = deSerialiser.Deserialize(xmlReader)

        Return tmpBDC
    End Function

I'm literally just trying to deserialise an xml file into an object.

I'm getting the error 'Is' expected at the line:
        deSerialiser = New XmlSerializer(typeof(tmpBDC))
0
scm0sml
Asked:
scm0sml
  • 5
  • 4
1 Solution
 
Bob LearnedCommented:
That is an example of mixing VB.NET and C# code:

 deSerialiser = New XmlSerializer(GetType(tmpBDC))

Bob
0
 
scm0smlAuthor Commented:
lol!!

ah soz.....im doing this for the first time and am ripping stuff of the net.

could you give a full vb.net example?
0
 
Bob LearnedCommented:
Example of what?

Bob
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
scm0smlAuthor Commented:
deserialising an xml file in vb.net 2.0
0
 
Bob LearnedCommented:
May I ask what the bigger picture is here?  What is using this functionality?

Bob
0
 
scm0smlAuthor Commented:
i will be receiving an object via a webservice.

at the moment tho i only have the serialised version of it in an xml file.

so i want to create the object using the xml so i can replicate receiving the object via the webservice and work with it from there.
0
 
Bob LearnedCommented:
So you have an object represented in an XML file, and you are trying to deserialize that object into a reference.

What is wrong with your code?  Are you getting exceptions?

Bob
0
 
scm0smlAuthor Commented:
Dim strDBname As String
        Dim oReg As Microsoft.Win32.RegistryKey
        oReg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Travelink\Configuration")
        strDBname = oReg.GetValue("TcatDatabase")

        Dim strQuoteID As String
        Dim _bdcImportFile As New BdcHandoffFile
        Dim _objTravelinkHandoff As New TravelinkHandoff
        '_bdcImportFile = ConvertXMLToBDC(_pathToExampleBDCFile)

        strQuoteID = CStr(_objTravelinkHandoff.CreateQuote(_bdcImportFile))

        MsgBox(strQuoteID)

gives me the error:
'Is' Expected

on line:
deSerialiser = New XmlSerializer(typeof(tmpBDC))        
0
 
Bob LearnedCommented:
Hmmm, you didn't use the change I suggested:

deSerialiser = New XmlSerializer(GetType(tmpBDC))

Bob
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now