none
vb2003 program reads xml. works on XP, fails on win7 RRS feed

  • Question

  • We have a VB2k3 app that has not been touched since 2005.  It runs perfectly on an XP box, but now it's installed on a win7 box, it is throwing a duplicateNameException: Cannot add a column named "FormattedReportObjects": a nested table with the same name already belongs to this DataTable.  The file being loaded is the same file in both cases.

    Any thoughts?  Is there a component that needs updating on the win7 box?  Other VB2k3 apps run ok on the win7 box.

    Jeremy


    Jeremy

    • Moved by Val MazurModerator Friday, July 6, 2012 1:22 PM (From:XML, System.Xml, MSXML and XmlLite)
    Wednesday, July 4, 2012 6:14 PM

All replies

  • So you use DataSet.ReadXml/ReadXmlSchema? I am not aware that anything has changed after 2003 (well there is http://support.microsoft.com/kb/316820 but that is about a fix in VS 2003). The problem with the DuplicateNameException comes up here ocasionally (for instance http://social.msdn.microsoft.com/Forums/en-US/xmlandnetfx/thread/38d50753-45a8-41c2-8512-222008c8e65c/) but the cause is then simply that the XML structure can not be mapped to a relational structure with tables and columns as column names need to be unique while XML child element names don't need to be unique.

    You have pointed out that the file being loaded is the same, I would ask you to double check that again.

    If it is the same file I am not sure what to suggest, I don't even have VS 2003 anymore to try to reproduce the problem.


    MVP Data Platform Development My blog

    Thursday, July 5, 2012 8:42 AM
  • Martin, thanks.  The code uses Dataset.LoadXML().  And yes, the file that fails on win7 is the same file that works on XP.  I made a test app using C# 2010 on my win7 box, and same problem.  Could be the XP components are forgiving a real problem that we have never noticed.

            const string xmlPath = @"c:\temp\List.xml";
            DataSet ds = new DataSet();
            FileStream fs = new FileStream(xmlPath, FileMode.Open);
                try
                {
                    ds.ReadXml(fs); <== exception thrown here.
                    foreach (DataTable table in ds.Tables)
                    {
                        Console.WriteLine("Table name: " + table.TableName);
                    }
                    Console.WriteLine("Test");
                }
                catch (Exception e) { Console.WriteLine(e.Message); }
                finally { fs.Close(); }


    Jeremy

    Thursday, July 5, 2012 3:56 PM
  • One more thing .. the xml is generated by Crystal, so I'll try to figure out the structure & walk the nodes.


    Jeremy

    Thursday, July 5, 2012 4:14 PM
  • And yet another factoid .. the app runs ok on one of our win7 boxes, but not on another one.  So I guess that something isn't installed that should be.

    Jeremy

    Thursday, July 5, 2012 5:31 PM
  • And yet another factoid .. the app runs ok on one of our win7 boxes, but not on another one.  So I guess that something isn't installed that should be.

    I don't think System.Data.DataSet depends on some optional stuff you could choose to install or not install, it is part of the .NET framework class library since version 1.0, in the assembly System.Data.dll. So I don't think it is an installation issue.

    What happens with your test app, does it work differently on those two machines?


    MVP Data Platform Development My blog

    Thursday, July 5, 2012 5:48 PM
  • the test app has the same behavior -- runs on one win7, not on another.  The win7 box that works is a development box that has vs2k3 installed, the others not.  My speculation is that perhaps an early framework isn't installed or not fully patched, and the app is attempting to use a later one which has some subtle difference. I don't recall if .net even does a "fall-forward" like that, so will need to check.

    Jeremy

    Thursday, July 5, 2012 6:36 PM
  • You'd better to check the version of your dll, is it the same with in XP? Or, try to re-install the old version of .net framework.

    Go go Doraemon!

    Tuesday, July 10, 2012 3:30 AM
  • Can you change this part of your code 

       FileStream fs = new FileStream(xmlPath, FileMode.Open);
                try
                {
                    ds.ReadXml(fs); <== exception thrown here.
                    foreach (DataTable table in ds.Tables)
                    {
                        Console.WriteLine("Table name: " + table.TableName);
                    }
                    Console.WriteLine("Test");
                }
                catch (Exception e) { Console.WriteLine(e.Message); }
                finally { fs.Close(); }

    to

                    ds.ReadXml(xmlPath)
                    foreach (DataTable table in ds.Tables)
                    {
                        Console.WriteLine("Table name: " + table.TableName);
                    }
                    Console.WriteLine("Test");
                }
                catch (Exception e) { Console.WriteLine(e.Message); }

    Should do the same



    Success
    Cor



    Wednesday, July 11, 2012 6:41 AM