Re: [Mono-dev] serialization of structured data in ArrayList
when i compile the code below and i run it, i've got the following exception: Unhandled Exception: System.InvalidOperationException: The type Car was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. can you help me, how can i solve it? how to serialize the non primitive type (ArrayList with the instances of the Car class)? thanks mirek mirek wrote: try to compile this code: using System; using System.IO; using System.Collections; using System.Xml.Serialization; public class Car { public string type; public int price; public Car( string type, int price ) { this.type = type; this.price = price; } } public class Config { static string filename = .configrc; public ArrayList list; public Config() { list = new ArrayList(); } public void Add( string type, int price ) { Car car = new Car( type, price ); list.Add( car ); } public void Save( Config config ) { using (FileStream fs = new FileStream(filename, FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(Config)); serializer.Serialize(fs, config); } } } class App { public static void Main() { Config config = new Config(); config.Add( truck, 200 ); config.Add( pickup, 100 ); Console.WriteLine( hello ); config.Save( config ); } } mirek Robert Jordan wrote: mirek wrote: hello i try to use serialization for storing of configuration in my app. the problem is, i've got some data stored in ArrayList, and they are not primitive types - they are instances of classes or some structs. so it looks like this: [Serializable] public class Entry { public string type; public int price; } [Serializable] public class CConfiguration { ... public ArrayList vehicle; ... } // in my app... Entry e = new Entry(); e.type = truck; e.price = 200; vehicle.Add( e ); but it doesnt work. how can i do that? What doesn't work? Did your get an exception? If so, which one? Robert ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list -- e-mail: [EMAIL PROTECTED] icq: 113397932 jabber: [EMAIL PROTECTED] homepage: http://www.intrak.sk/~binas english: Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html slovak: prosim, neposielajte mi prilohy vo formatoch .doc a .ppt (power point) precitajte si http://www.fsf.org/philosophy/no-word-attachments.cs.html ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] serialization of structured data in ArrayList
I never tried to serialize an ArrayList, but I think you had better to serialize a strongly typed array of Car objects. An ArrayList is a too complex structure. If you need an ArrayList on both sides of serialization, you can use the constructor of ArrayList that takes an ICollection. Arrays are ICollections so you can pass the received Car[] to the ArrayList constructor. Kornél - Original Message - From: mirek [EMAIL PROTECTED] To: mirek [EMAIL PROTECTED] Cc: mono-devel-list@lists.ximian.com Sent: Monday, December 19, 2005 10:56 AM Subject: Re: [Mono-dev] serialization of structured data in ArrayList when i compile the code below and i run it, i've got the following exception: Unhandled Exception: System.InvalidOperationException: The type Car was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. can you help me, how can i solve it? how to serialize the non primitive type (ArrayList with the instances of the Car class)? thanks mirek mirek wrote: try to compile this code: using System; using System.IO; using System.Collections; using System.Xml.Serialization; public class Car { public string type; public int price; public Car( string type, int price ) { this.type = type; this.price = price; } } public class Config { static string filename = .configrc; public ArrayList list; public Config() { list = new ArrayList(); } public void Add( string type, int price ) { Car car = new Car( type, price ); list.Add( car ); } public void Save( Config config ) { using (FileStream fs = new FileStream(filename, FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(Config)); serializer.Serialize(fs, config); } } } class App { public static void Main() { Config config = new Config(); config.Add( truck, 200 ); config.Add( pickup, 100 ); Console.WriteLine( hello ); config.Save( config ); } } mirek Robert Jordan wrote: mirek wrote: hello i try to use serialization for storing of configuration in my app. the problem is, i've got some data stored in ArrayList, and they are not primitive types - they are instances of classes or some structs. so it looks like this: [Serializable] public class Entry { public string type; public int price; } [Serializable] public class CConfiguration { ... public ArrayList vehicle; ... } // in my app... Entry e = new Entry(); e.type = truck; e.price = 200; vehicle.Add( e ); but it doesnt work. how can i do that? What doesn't work? Did your get an exception? If so, which one? Robert ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list -- e-mail: [EMAIL PROTECTED] icq: 113397932 jabber: [EMAIL PROTECTED] homepage: http://www.intrak.sk/~binas english: Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html slovak: prosim, neposielajte mi prilohy vo formatoch .doc a .ppt (power point) precitajte si http://www.fsf.org/philosophy/no-word-attachments.cs.html ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] serialization of structured data in ArrayList
wow - great - it works. thanks a lot :-)) yes - the exception told me what to do, i just didnt know how to use xmlinclude. thanks one more time ;) maybe - two questions: 1. it is good to use xml serialization or binary? as i read the articles, the binary is faster, but maybe not so usefull when need to change the configuration file by my own. 2. in this case (of this example code) - is it better to use structure Car or class Car? mirek Bjarke V. Lindberg wrote: mirek wrote: [Serializable] public class Car { public string type; public int price; public Car() {} We'll need a default constructor if we don't implement ISerializable. public Car( string type, int price ) { this.type = type; this.price = price; } } We gotta know our Car type. [Serializable] [XmlInclude(typeof(Car))] public class Config { static string filename = .configrc; [...] The error message of the Exception told you :) /B.Serializable :) -- e-mail: [EMAIL PROTECTED] icq: 113397932 jabber: [EMAIL PROTECTED] homepage: http://www.intrak.sk/~binas english: Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html slovak: prosim, neposielajte mi prilohy vo formatoch .doc a .ppt (power point) precitajte si http://www.fsf.org/philosophy/no-word-attachments.cs.html ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Mono debugger : Inconsistency detected by ld.so:
I've seen that the debugger as changed these days... I'm working with gentoo with libc with tls enabled... I've updated my debugger from svn, and I always get : [EMAIL PROTECTED] ~/mono/debugger $ mdb Inconsistency detected by ld.so: ../sysdeps/generic/dl-tls.c: 72: _dl_next_tls_modid: Assertion `result = _rtld_local._dl_tls_max_dtv_idx' failed! Does somebody could help me on this issue? thanks ___Ce message et les éventuels documents joints peuvent contenir des informations confidentielles.Au cas où il ne vous serait pas destiné, nous vous remercions de bien vouloir le supprimer et en aviser immédiatement l'expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.Les communications sur internet n'étant pas sécurisées, l'intégrité de ce message n'est pas assurée et la société émettrice ne peut être tenue pour responsable de son contenu. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] mod_mono on Windows
Hello Gonzalo, As we talked earlier, I'm sending you the patches for mod_mono on windows. On patch mod_mono-win32-3, const int MAXARGS = 21; should work using #define , but on Windows, as const int it does not work, so for now it is hardcoded. I think the best should be testing with define. I have discussed it with Algel Marin (the patch creator) and there should be no problem on using define. There are a few issues we should discuss also: * If the autohosting is used, mod-mono-server does not identify paths as applications (maybe we didn't figure out how to make it work) * We need to determine also a good LISTEN_PORT value * With some releases you can configure the directives with spaces and backslashes and then in the next one the behavior changes, the directive that accepted spaces, makes mono fail and the one that gave problems starts accepting them, for example on 1.1.10 MonoDocumentRootDir does not work if you configure it with a path that has spaces, mono gives exceptions until you use the old 8.3 format for the path. On 1.1.9 MonoExecutablePath gave similar problems, but in 1.1.10 it works. (on a first impression I would say it could be some platform path mapping glitch on the base classlib) * The build process on windows depends on cygwin (win32 glib builds) * fork_mod_mono_server does two different tasks: first it prepares the arguments to launch mod-mono-server.exe, then It setups the environment needed for the fork and forks the process. The arguments needed for win32 are just the same needed for linux, just the fork stuff changes. To ease maintenance the args should be setup in other function and #ifdef WIN32 should be used to declare the right function. The patch mod_mono-win32-3 handles fork_mod_mono on windows ... it should be rewritten as stated earlier. The patches were designed in a manner to keed mod_mono the closest from original. There could be some corrections in order to merge it with the actual code and keed it portable. If there is no problem, me and Angel Marin could do the refactoring as stated on this mail and I could commit it later. -- Regards, Alexandre Rocha Lima e Marcondes P4 Tecnologia e Desenvolvimento Humano [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] www.p4tecnologia.com alexandre.p4tecnologia.com Projetos: MonoBrasil MonoBASIC ACBr Freedom ERP To validate this message's signature follow the instructions: http://www.cacert.org/index.php?id=3lang=en_US smime.p7s Description: S/MIME cryptographic signature ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Compilling Mono 1.1.10 on Sun Solaris 9
isnormal is no longer used in the svn head version. It was changed in svn r54327. Peter -Original Message- From: Vorobiev Maksim [EMAIL PROTECTED] To: mono-devel-list@lists.ximian.com Date: Monday, 19 December, 2005 09:49 Subject: [Mono-dev] Compilling Mono 1.1.10 on Sun Solaris 9 Good day. I try to compile Mono 1.1.10 on Sun Solaris 9 (SPARC), but it throws error at /mono/dis/get.c: undefined reference to `isnormal'. I've found submitted bug about the same problem, but for Solaris 8. Bug ? 77034. The problem is that the function isnormal not implemented in standart Sun's libm, but only in additional libsunmath, that ships with Sun Workshop. Is it possible to break this dependance? As I can see, this call branches some sort of print output (debug propose?). Is it OK to comment out call to isnormal, or it breaks something internal? May be it's good to make conditional compilation branch for Sun platform? Thank you. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
RE: [Mono-dev] Compilling Mono 1.1.10 on Sun Solaris 9
I believe that that library is in /usr/ucblib and is there by default (I don't know that for sure, since we have Workshop installed). That issue is just a path issue and there will likely be others (I haven't tried building Solaris Mono for a while so I don't know what sort of shape it is in). Gary M. Smithrud Haley Systems, Inc. Phone: 724-934-7853 [EMAIL PROTECTED] www.haley.com Moving at the Speed of Change -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vorobiev Maksim Sent: Monday, December 19, 2005 11:49 AM To: mono-devel-list@lists.ximian.com Subject: [Mono-dev] Compilling Mono 1.1.10 on Sun Solaris 9 Good day. I try to compile Mono 1.1.10 on Sun Solaris 9 (SPARC), but it throws error at /mono/dis/get.c: undefined reference to `isnormal'. I've found submitted bug about the same problem, but for Solaris 8. Bug № 77034. The problem is that the function isnormal not implemented in standart Sun's libm, but only in additional libsunmath, that ships with Sun Workshop. Is it possible to break this dependance? As I can see, this call branches some sort of print output (debug propose?). Is it OK to comment out call to isnormal, or it breaks something internal? May be it's good to make conditional compilation branch for Sun platform? Thank you. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] `System.Diagnostics.Process' is defined multiple times
Hi, Im'trying to compile a program which uses System.Diagnostics.Process to execute a C-program, but my program also uses System.I0.Ports from the 2.0 library and this gives a conflict because System.Diagnostics.Process is defined multiple times (in the 1.0 and 2.0 library). Could someone help me to solve this problem ? I don't have much experience with mono. Compiler output: mcs Main.cs Config.cs Vectors.cs Gui.cs Comm.cs -r:/usr/lib/mono/2.0/System.dll -out:Asic_Test_Machine.exe -pkg:gtk-sharp-2.0 -pkg:gecko-sharp-2.0; Comm.cs(229,4): error CS0433: The imported type `System.Diagnostics.Process' is defined multiple times /usr/lib/mono/2.0/System.dll: `System.Diagnostics.Process', name of symbol related to previous error /usr/lib/mono/1.0/System.dll: `System.Diagnostics.Process', name of symbol related to previous error Compilation failed: 1 error(s), 0 warnings make: *** [Asic_Test_Machine.exe] Error 1 Greetings, Jurgen ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] `System.Diagnostics.Process' is defined multiple times
Hi, Try the gmcs compiler it will automatically use the 2.0 libraries, so no need to do -r:/usr/lib/mono/2.0/System.dll. Zoltan On 12/19/05, Jurgen Schoeters [EMAIL PROTECTED] wrote: Hi, Im'trying to compile a program which uses System.Diagnostics.Process to execute a C-program, but my program also uses System.I0.Ports from the 2.0 library and this gives a conflict because System.Diagnostics.Process is defined multiple times (in the 1.0 and 2.0 library). Could someone help me to solve this problem ? I don't have much experience with mono. Compiler output: mcs Main.cs Config.cs Vectors.cs Gui.cs Comm.cs -r:/usr/lib/mono/2.0/System.dll -out:Asic_Test_Machine.exe -pkg:gtk-sharp-2.0 -pkg:gecko-sharp-2.0; Comm.cs(229,4): error CS0433: The imported type `System.Diagnostics.Process' is defined multiple times /usr/lib/mono/2.0/System.dll: `System.Diagnostics.Process', name of symbol related to previous error /usr/lib/mono/1.0/System.dll: `System.Diagnostics.Process', name of symbol related to previous error Compilation failed: 1 error(s), 0 warnings make: *** [Asic_Test_Machine.exe] Error 1 Greetings, Jurgen ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] serialization of structured data in ArrayList
On Mon, 2005-12-19 at 14:26 +0100, mirek wrote: 1. it is good to use xml serialization or binary? as i read the articles, the binary is faster, but maybe not so usefull when need to change the configuration file by my own. If it's not performance critical, I would suggest going with the more easily debugged solution, in this case XML serialization. 2. in this case (of this example code) - is it better to use structure Car or class Car? If you're using ArrayList, use a class, not a structure, since then you won't have extra boxing/unboxing overhead. - Jon ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] System.Threading Bug in Mono 1.1.10 ( Regression )
Hi, This isn't a regression. Thread.Interrupt never worked in mono, however, in older versions, it did nothing, causing code using it to silently fail, now it throws a NotImplementedException. http://bugzilla.ximian.com/show_bug.cgi?id=74525 Zoltan On 12/20/05, Victor Romero [EMAIL PROTECTED] wrote: Hi, I have been reading the document An ASM specification of C# threads and the .NET memory model by Robert F. Stärk and Egon Börger and there they have an example about a bug in .NET 1.1, in Mono 1.9.2 it works perfectly, but now, in Mono 1.1.10 It gives me and exception /*The code*/ using System; using System.Threading; class Account { private decimal balance = 0.0M; public void Deposit() { lock (this) { try { Monitor.Wait(this); } finally { balance += 100.00M; } } } public static void Main() { Account a = new Account(); Thread t = new Thread(new ThreadStart(a.Deposit)); t.Start(); Thread.Sleep(100); lock (a) { Console.WriteLine(a.balance); // Output: 0 Monitor.Pulse(a); t.Interrupt(); Thread.Sleep(100); Console.WriteLine(a.balance); // Output: 100.00 (.NET 1.1 bug) } } } .NET 1.1 C:\Documents and Settings\Pavilion\My Documents\SharpDevelop Projects\Hilo\bin\DebugHilo.exe 0 100.00 Mono 1.1.9.2 -bash-3.00$ mono Hilo.exe 0 0 Mono 1.1.10 -bash-3.00$ mono Hilo.exe 0 Unhandled Exception: System.NotImplementedException: The requested feature is not implemented. in 0x00028 System.Threading.Thread:Interrupt () in 0x00108 Account:Main () I'm still working on how to run XSP under Solaris 10 in a SPARC with Mono 1.1.10 ... Victor Romero Messenger: [EMAIL PROTECTED] Business Web Page: http://www.dsnibble.com.mx Personal Web Page: http://linux.ipn.mx/cms/space/VictorRomero Blog Web Page: http://elcarteldetux.blogspot.com ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list