Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. XML issues

XML issues

Scheduled Pinned Locked Moved Visual Basic
csharptestingbeta-testingxml
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StuBaum
    wrote on last edited by
    #1

    Hi All, I have this function to retrieve the version from a vb.net manifest file that is giving me fits. I swear that it worked when I went to bed late, late, last night but when I got up this morning it would return nothing. It has to be something simple that I am overlooking, but for the life of me I can't see it and am starting to cuss Microsoft and their *&$#^# XML ^#%(($ reader piece of &^^#@**$ bla, bla, bla. So, if anybody can pull my fat out of the fire it would be appreciated. Here is the stoned stupid, bone simple, 3rd grade routine that I think outta work. Private Function GetManifestVer(ByVal strManifestFile As String) As String GetManifestVer = "" Dim xmlr As XmlTextReader xmlr = New XmlTextReader(strManifestFile) While Not xmlr.EOF xmlr.Read() If xmlr.Name = "entryPoint" Then If xmlr.IsStartElement Then GetManifestVer = xmlr.GetAttribute("version") Exit While End If End If End While xmlr.Close() End Function You can pass any vb.net manifest to it. I am using the [application].exe.manifest file created by a compile. I sure any manifest file will do for testing. So help me out before I start beating this computer like a red headed stepchild. Thanks - Stu

    J 1 Reply Last reply
    0
    • S StuBaum

      Hi All, I have this function to retrieve the version from a vb.net manifest file that is giving me fits. I swear that it worked when I went to bed late, late, last night but when I got up this morning it would return nothing. It has to be something simple that I am overlooking, but for the life of me I can't see it and am starting to cuss Microsoft and their *&$#^# XML ^#%(($ reader piece of &^^#@**$ bla, bla, bla. So, if anybody can pull my fat out of the fire it would be appreciated. Here is the stoned stupid, bone simple, 3rd grade routine that I think outta work. Private Function GetManifestVer(ByVal strManifestFile As String) As String GetManifestVer = "" Dim xmlr As XmlTextReader xmlr = New XmlTextReader(strManifestFile) While Not xmlr.EOF xmlr.Read() If xmlr.Name = "entryPoint" Then If xmlr.IsStartElement Then GetManifestVer = xmlr.GetAttribute("version") Exit While End If End If End While xmlr.Close() End Function You can pass any vb.net manifest to it. I am using the [application].exe.manifest file created by a compile. I sure any manifest file will do for testing. So help me out before I start beating this computer like a red headed stepchild. Thanks - Stu

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      I tried this adapted version of your code:

      Private Function GetManifestVer(ByVal strManifestFile As String) As String
      	Try
      		GetManifestVer = ""
      		Dim xmlr As XmlTextReader
      		xmlr = New XmlTextReader(strManifestFile)
      		While Not xmlr.EOF
      			xmlr.Read()
      			If xmlr.Name = "entryPoint" Then
      				If xmlr.IsStartElement Then
      					GetManifestVer = xmlr.GetAttribute("version")
      					Exit While
      				Else
      					GetManifestVer = "StartElement not found"
      				End If
      			Else
      				GetManifestVer = "entryPoint not found"
      			End If
      		End While
      		xmlr.Close()
      	Catch ex As Exception
      		Return ex.Message
      	End Try
      End Function
      

      It does not find "entryPoint". Can there be a simple syntax error, or maybe it is case sensitive or something ?

      My advice is free, and you may get what you paid for.

      S 1 Reply Last reply
      0
      • J Johan Hakkesteegt

        I tried this adapted version of your code:

        Private Function GetManifestVer(ByVal strManifestFile As String) As String
        	Try
        		GetManifestVer = ""
        		Dim xmlr As XmlTextReader
        		xmlr = New XmlTextReader(strManifestFile)
        		While Not xmlr.EOF
        			xmlr.Read()
        			If xmlr.Name = "entryPoint" Then
        				If xmlr.IsStartElement Then
        					GetManifestVer = xmlr.GetAttribute("version")
        					Exit While
        				Else
        					GetManifestVer = "StartElement not found"
        				End If
        			Else
        				GetManifestVer = "entryPoint not found"
        			End If
        		End While
        		xmlr.Close()
        	Catch ex As Exception
        		Return ex.Message
        	End Try
        End Function
        

        It does not find "entryPoint". Can there be a simple syntax error, or maybe it is case sensitive or something ?

        My advice is free, and you may get what you paid for.

        S Offline
        S Offline
        StuBaum
        wrote on last edited by
        #3

        Thanks for taking a look. Both my code and yours finds the 'entryPoint' element on my box but neither can find the 'version' attribute. Actually my code did work and then quit at some point. Go figure, makes me think that the Microsoft implementation of the XML reader is not ready for prime time. But as soon as I think that I am sure to get slapped in the face by an error that was my doing, that is usually the case. I would like to do it with XML, but it is costing to much time. I seem to be doing what all of the other examples on the web are doing. I guess it is back to the old fashion parse. Did you actually try it on your box? With a .exe.manifest file created from a build?

        J 1 Reply Last reply
        0
        • S StuBaum

          Thanks for taking a look. Both my code and yours finds the 'entryPoint' element on my box but neither can find the 'version' attribute. Actually my code did work and then quit at some point. Go figure, makes me think that the Microsoft implementation of the XML reader is not ready for prime time. But as soon as I think that I am sure to get slapped in the face by an error that was my doing, that is usually the case. I would like to do it with XML, but it is costing to much time. I seem to be doing what all of the other examples on the web are doing. I guess it is back to the old fashion parse. Did you actually try it on your box? With a .exe.manifest file created from a build?

          J Offline
          J Offline
          Johan Hakkesteegt
          wrote on last edited by
          #4

          I am not entirely sure what it is you need to do, as I myself have never needed to access manifest files (in fact I never even looked at one until your post), so I just found one and ran it against your code. All I got was "entryPoint not found"

          My advice is free, and you may get what you paid for.

          S 1 Reply Last reply
          0
          • J Johan Hakkesteegt

            I am not entirely sure what it is you need to do, as I myself have never needed to access manifest files (in fact I never even looked at one until your post), so I just found one and ran it against your code. All I got was "entryPoint not found"

            My advice is free, and you may get what you paid for.

            S Offline
            S Offline
            StuBaum
            wrote on last edited by
            #5

            I am just trying to get the version value from a manifest file that was created by a build/compile. The file can be found in any applications \bin\Release\ServiceInvoice.exe.manifest folder. I am writing my own Application updater. I want my apps to be under easily accessible under the 'program files' directory so click-once publish is not an option. I have written a small routine that downloads the manifest from my \bin\Release folder (which is a virtual dir under my IIS) and then extracts the version via the routine (GetManifestVer) that we are discussing. compares it with its own version and makes a decision to download the 'exe' or not. Enclosed is the code, it is very raw and once working I will stick in more parameters and error trapping before it is done. But it will go something like this . Private Sub UpdateApp() Dim MVer As String = "" Dim AVer() As String = Split(My.Application.Info.Version.ToString, ".", True) Dim AName As String = My.Application.Info.AssemblyName Dim LocalPath As String = My.Application.Info.DirectoryPath Dim LocalApp As String = LocalPath & "\" & AName & ".exe" Dim RemoteApp As String = "http://Stu-Laptop/IMS/" & AName & "/" & AName & ".exe" Dim RemoteManifestFile As String = "http://Stu-Laptop/IMS/" & AName & "/" & AName & ".exe.manifest" Dim LocalManifestFile As String = My.Application.Info.DirectoryPath & "\Manifest.xml" Dim xmlr As XmlTextReader Dim WebConnection As New WebClient() Dim CurV() As String Try If File.Exists(LocalManifestFile) Then File.Delete(LocalManifestFile) WebConnection.DownloadFile(RemoteManifestFile, LocalManifestFile) Catch ex As Exception MsgBox("Error retrieving web file", ex.Message) Exit Sub End Try xmlr = New XmlTextReader(LocalManifestFile) While Not xmlr.EOF xmlr.Read() If xmlr.Name = "entryPoint" Then If xmlr.IsStartElement Then MVer = xmlr.GetAttribute("version") Exit While End If End If End While xmlr.Close() If File.Exists(LocalManifestFile) Then File.Delete(LocalManifestFile) If MVer = "" Then Exit Sub CurV = Split(MVer, ".", True) If (AVer(0) < CurV(0)) Or (AVer(1) < CurV(1)) Or (AVer(2) < CurV(2)) Or (AVer(3) < CurV(3)) Then FileCopy(L

            J 1 Reply Last reply
            0
            • S StuBaum

              I am just trying to get the version value from a manifest file that was created by a build/compile. The file can be found in any applications \bin\Release\ServiceInvoice.exe.manifest folder. I am writing my own Application updater. I want my apps to be under easily accessible under the 'program files' directory so click-once publish is not an option. I have written a small routine that downloads the manifest from my \bin\Release folder (which is a virtual dir under my IIS) and then extracts the version via the routine (GetManifestVer) that we are discussing. compares it with its own version and makes a decision to download the 'exe' or not. Enclosed is the code, it is very raw and once working I will stick in more parameters and error trapping before it is done. But it will go something like this . Private Sub UpdateApp() Dim MVer As String = "" Dim AVer() As String = Split(My.Application.Info.Version.ToString, ".", True) Dim AName As String = My.Application.Info.AssemblyName Dim LocalPath As String = My.Application.Info.DirectoryPath Dim LocalApp As String = LocalPath & "\" & AName & ".exe" Dim RemoteApp As String = "http://Stu-Laptop/IMS/" & AName & "/" & AName & ".exe" Dim RemoteManifestFile As String = "http://Stu-Laptop/IMS/" & AName & "/" & AName & ".exe.manifest" Dim LocalManifestFile As String = My.Application.Info.DirectoryPath & "\Manifest.xml" Dim xmlr As XmlTextReader Dim WebConnection As New WebClient() Dim CurV() As String Try If File.Exists(LocalManifestFile) Then File.Delete(LocalManifestFile) WebConnection.DownloadFile(RemoteManifestFile, LocalManifestFile) Catch ex As Exception MsgBox("Error retrieving web file", ex.Message) Exit Sub End Try xmlr = New XmlTextReader(LocalManifestFile) While Not xmlr.EOF xmlr.Read() If xmlr.Name = "entryPoint" Then If xmlr.IsStartElement Then MVer = xmlr.GetAttribute("version") Exit While End If End If End While xmlr.Close() If File.Exists(LocalManifestFile) Then File.Delete(LocalManifestFile) If MVer = "" Then Exit Sub CurV = Split(MVer, ".", True) If (AVer(0) < CurV(0)) Or (AVer(1) < CurV(1)) Or (AVer(2) < CurV(2)) Or (AVer(3) < CurV(3)) Then FileCopy(L

              J Offline
              J Offline
              Johan Hakkesteegt
              wrote on last edited by
              #6

              I just opened up a few of these manifest files (with PSPad) and they all look something like this: Neither the ones made with VS 2003 nor the ones made with VS 2008 had any mention of a tag or attribute called "entryPoint", they do however all have the tag "assemblyIdentity" with a "version" attribute. Is it possible that the manifest file you used (late the day-before-yesterday) is/was for some reason different from the average manifest file ? As the problem seems to be that the element "entryPoint" is simply not found, perhaps you should try to open your manifest with some editor, and see if there isn't some other element you could check for? My advice is free, and you may get what you paid for.

              S 1 Reply Last reply
              0
              • J Johan Hakkesteegt

                I just opened up a few of these manifest files (with PSPad) and they all look something like this: Neither the ones made with VS 2003 nor the ones made with VS 2008 had any mention of a tag or attribute called "entryPoint", they do however all have the tag "assemblyIdentity" with a "version" attribute. Is it possible that the manifest file you used (late the day-before-yesterday) is/was for some reason different from the average manifest file ? As the problem seems to be that the element "entryPoint" is simply not found, perhaps you should try to open your manifest with some editor, and see if there isn't some other element you could check for? My advice is free, and you may get what you paid for.

                S Offline
                S Offline
                StuBaum
                wrote on last edited by
                #7

                Yes my manifests seen a little more complicated. But I am glad to inform you that I have resolved the issue. Like usual it was me. When you work very late into the night strange things happen, specially when there is a full moon. I usually quit when the computer gives a loud beep in response to some error & it scares me out of my chair mumbling something like 'What the *)%(&^^ was that?'. below is a piece of my manifest. Its a pretty long manifest - would take 2 to 3 pages to print out. The correct node to search for is assemblyIdentity not entry point. Both my raw code and your error trapped code works correctly when given the right value. I have finished my routines and it works like a dream, a seamless, silent, transparent check of the version & then download if necessary of a new exe and kick off. User never sees a thing. It reverts back to the old exe if it fails at any point. Its nice now, all I have to do is compile, nothing else is required, I don't have to make any files set any flags etc. I do have another issue though. It seems like I got myself into some kind of debug/Edit purgatory where I can't edit in the debug mode. It started when I put some values in the debug properties window for testing my command line functions. I get cute little padlocks on my code page tab and a error that says 'Changes are not allowed when the debugger has been attached to an already running

                S 1 Reply Last reply
                0
                • S StuBaum

                  Yes my manifests seen a little more complicated. But I am glad to inform you that I have resolved the issue. Like usual it was me. When you work very late into the night strange things happen, specially when there is a full moon. I usually quit when the computer gives a loud beep in response to some error & it scares me out of my chair mumbling something like 'What the *)%(&^^ was that?'. below is a piece of my manifest. Its a pretty long manifest - would take 2 to 3 pages to print out. The correct node to search for is assemblyIdentity not entry point. Both my raw code and your error trapped code works correctly when given the right value. I have finished my routines and it works like a dream, a seamless, silent, transparent check of the version & then download if necessary of a new exe and kick off. User never sees a thing. It reverts back to the old exe if it fails at any point. Its nice now, all I have to do is compile, nothing else is required, I don't have to make any files set any flags etc. I do have another issue though. It seems like I got myself into some kind of debug/Edit purgatory where I can't edit in the debug mode. It started when I put some values in the debug properties window for testing my command line functions. I get cute little padlocks on my code page tab and a error that says 'Changes are not allowed when the debugger has been attached to an already running

                  S Offline
                  S Offline
                  StuBaum
                  wrote on last edited by
                  #8

                  It seems that I need quotes around the XML. Let me try that again. "' '"

                  J 1 Reply Last reply
                  0
                  • S StuBaum

                    It seems that I need quotes around the XML. Let me try that again. "' '"

                    J Offline
                    J Offline
                    Johan Hakkesteegt
                    wrote on last edited by
                    #9

                    You should also considering laying off the late night coding parties, and get yourself some good old fashion sex, drugs and rock 'n roll... and if you feel you must, some sleep. ;)

                    My advice is free, and you may get what you paid for.

                    S 1 Reply Last reply
                    0
                    • J Johan Hakkesteegt

                      You should also considering laying off the late night coding parties, and get yourself some good old fashion sex, drugs and rock 'n roll... and if you feel you must, some sleep. ;)

                      My advice is free, and you may get what you paid for.

                      S Offline
                      S Offline
                      StuBaum
                      wrote on last edited by
                      #10

                      You got that right, but unfortunately those days are gone, over here in the US, unemployment is running rampant. The programming field has been decimated by outsourcing. H1 Visa's get what jobs are left. The government has declared war on the citizens, stealing everything we got & giving it away to their cronies who will give some of it back to them by way of speaker fees, campaign contributions, and graft of all sorts. Our Constitution has been totally trashed by an imaginary war on terror as if we didn't know who is really behind it. Sex?, Drugs?, Rock & Roll?, Sleep? All of those things a dim memory of days long gone. Hope things are better where your at. Enjoy it while you can. The New World Order is comming.... Thanks again for your support Stu. "Truth is treason in the Empire of Lies."

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups