[Mono-devel-list] Problems wth ds.ReadXml () (DataSet)
Eran Domb
erand at mainsoft.com
Sun Feb 8 07:19:13 EST 2004
Philip Van Hoof wrote:
>Hi there,
>
>When I want to read a DataSet from an XML-file from both a
>ManifestResource or a file I always get this Exception:
>
>"A null value was found where an object instance was required"
>
>I am running mono-0.30 on a Fedora Core 1
>
>This is the code I am trying:
>
>DataSet conf = new DataSet();
>Assembly a = c.GetType().Assembly;
>System.IO.Stream ConfigFile =
>a.GetManifestResourceStream("Cronos.Xnet.XnetDotBe.DAL.DALConfig.xml");
>-> Exception point <-
>conf.ReadXml (ConfigFile);
>-> Exception point <-
>
>When I loop the resource-names I do get the resource
>"Cronos.Xnet.XnetDotBe.DAL.DALConfig.xml" in the string-array (so the
>resource actually does exist). Note that it has been compiled using VS
>2003 .NET (not using Mono).
>
>I can also try something like :
>
>conf.ReadXml ("/home/freax/cvs/XnetDotBe/XnetDotBe/bin/DALConfig.xml");
>
>And read the XML from a file on my filesystem (and indeed, that file
>'does' exist, of course -I am not VERY stupid, you know-)
>
>'The line' (so not my code) will throw the same exception
>
>
>I am indeed running this code using xsp (it's a ASP.NET website, yes)
>
>
>This is how my xml-file looks (nothing THAT strange about it huh):
>
>On Microsoft .NET it will load the DataSet with a table Config and
>columns like "ConnectionString" and "DatabaseType". This code works
>1000% perfectly on the Microsoft .NET framework (and it's not very very
>platform specific, imho)
>
><?xml version="1.0" encoding="utf-8" ?>
><Config>
>
><!-- Database connectivity settings //-->
> <ConnectionString>server=localhost;User
>ID=xnet;Password=xnet;database=XnetDotBe</ConnectionString>
> <DatabaseType>SqlServer</DatabaseType>
>
><!-- Other possibilities //-->
><!-- <ConnectionString>server=W2SK-MSSQL;User
>ID=sa;Password=;database=Default</ConnectionString> //-->
><!-- <DatabaseType>Oracle</DatabaseType> //-->
><!-- <DatabaseType>MySQL</DatabaseType> //-->
><!-- <DatabaseType>PostgreSQL</DatabaseType> //-->
><!-- <DatabaseType>Odbc</DatabaseType> //-->
><!-- <DatabaseType>SqlServer</DatabaseType> //-->
>
><!-- The Implementations for each Interface //-->
>
><IProject>Cronos.Xnet.XnetDotBe.DAL.Implementations.SqlServer.Project</IProject>
> <IProject.Assembly>DAL</IProject.Assembly>
>
><IEmployee>Cronos.Xnet.XnetDotBe.DAL.Implementations.SqlServer.Employee</IEmployee>
> <IEmployee.Assembly>DAL</IEmployee.Assembly>
> <ICustomer>Cronos.Xnet.XnetDotBe.DAL.Customer</ICustomer>
> <ICustomer.Assembly>DAL</ICustomer.Assembly>
> <ITechDomain>Cronos.Xnet.XnetDotBe.DAL.TechDomain</ITechDomain>
> <ITechDomain.Assembly>DAL</ITechDomain.Assembly>
> <ITechnology>Cronos.Xnet.XnetDotBe.DAL.Technology</ITechnology>
> <ITechnology.Assembly>DAL</ITechnology.Assembly>
>
></Config>
>
>
>
>_______________________________________________
>Mono-devel-list mailing list
>Mono-devel-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
>
Hello,
There is a problem reading xml file that does not have a DataSet element
as a root.
I can suggest a workaround - just add to the xml a DataSet element, exp:
<?xml version="1.0" encoding="utf-8" ?>
<MyDataSet>
<Config>
<!-- Database connectivity settings //-->
<ConnectionString>server=localhost;User
ID=xnet;Password=xnet;database=XnetDotBe</ConnectionString>
<DatabaseType>SqlServer</DatabaseType>
<!-- Other possibilities //-->
<!-- <ConnectionString>server=W2SK-MSSQL;User
ID=sa;Password=;database=Default</ConnectionString> //-->
<!-- <DatabaseType>Oracle</DatabaseType> //-->
<!-- <DatabaseType>MySQL</DatabaseType> //-->
<!-- <DatabaseType>PostgreSQL</DatabaseType> //-->
<!-- <DatabaseType>Odbc</DatabaseType> //-->
<!-- <DatabaseType>SqlServer</DatabaseType> //-->
<!-- The Implementations for each Interface //-->
<IProject>Cronos.Xnet.XnetDotBe.DAL.Implementations.SqlServer.Project</IProject>
<IProject.Assembly>DAL</IProject.Assembly>
<IEmployee>Cronos.Xnet.XnetDotBe.DAL.Implementations.SqlServer.Employee</IEmployee>
<IEmployee.Assembly>DAL</IEmployee.Assembly>
<ICustomer>Cronos.Xnet.XnetDotBe.DAL.Customer</ICustomer>
<ICustomer.Assembly>DAL</ICustomer.Assembly>
<ITechDomain>Cronos.Xnet.XnetDotBe.DAL.TechDomain</ITechDomain>
<ITechDomain.Assembly>DAL</ITechDomain.Assembly>
<ITechnology>Cronos.Xnet.XnetDotBe.DAL.Technology</ITechnology>
<ITechnology.Assembly>DAL</ITechnology.Assembly>
</Config>
</MyDataSet>
More information about the Mono-devel-list
mailing list