.net - Npgsql reader type cast error (was: mono does not serialize complex types well) -
Am I right that the serializing complex type is not implemented in Mono 2.4.2 yet, or have I made a mistake?
When I call my remote function, I get an error message:
Can not insert destination type from source type System.Runtime.Remoting Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy RP, iMessage Message, System.Exception & exc, System.Object [] & amp; out_args) [0x00000]
This is a remote function, instead when I use thestring []
, I got the same result.String
makes your way nicely.Public listing & lt; String & gt; GetHist () {NpgsqlConnection conn = New NpgsqlConnection (ConnectStr); Conn.Open (); String cmd = "select from history"; Npgsql command command = new NPGSQL COMMAND (CMD, CON); & Lt; String & gt; S = new list & lt; String & gt; (); {NpgsqlDataReader dr = command.ExecuteReader () Try it; If (Dr. Reid ()) {for (int i = 0; i & lt; dr.fieldCount; i ++) s.Add (dr.getString (i)); } And s.Add ("(hehe)"); } Finally {conn.Close (); } Return S; }
caller:
list & lt; String & gt; W = remoteClass.GetHist (); Foreach (in String S) console Type (s + ","); Console.WriteLine (); I have discovered this:
What about seriality compatibility? Can I serialize an object in mono and can iterize in MSNTT or vice versa?
The serialization format implemented in Mono is fully compatible with MSNT. However, there is not enough to be a compatible format. In order to successfully exchange sequential objects, related sections require equal internal structure (i.e., same public and private sector) in both sides.
If you are sorting your classes, then there is no problem, then you have control over the assemblies and classes since being used for the numbering.
However, if you are serializing objects from the framework, the sequential compatibility is not guaranteed, since the internal structure of those objects can be different. This compatibility is not guaranteed even between different MS.NET versions or mono versions.
Our policy is to try our best to create relevant framework sections between Mono and MS.NET, but sometimes it is not possible because the internal implementation is very different, even when we notice that To change the class making it compatible with MS.NET, we lose compatibility with older versions of Mono.
In summary, you think designing an application that will run in different environments and platforms, which are not in your control, and which (either using remote, plain files or whatever ,) Need to share serial objects, you should be careful with what shared objects, and avoid objects when possible from the framework.
(Note that this only applies to serializers based on the System.Runtime.Serialization framework, and does not apply to XmlSerializer).
However, this also does not work between the one- 2.4.2 and the second mono -2.4.2 application.
The problem is in Npgsql so I'll change it to the title. I think these two rows will be the same, both should return the
string
, but the first does not work:dr.getstring (i) dr [i ]. ToString ()
To make debugging even more difficult, pure remoting has passed the error on behalf of the collar.
Comments
Post a Comment