[Mono-bugs] [Bug 565616] New: InvalidCastException when storing a not IConvertible value in a string datacolumn.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Dec 17 09:48:32 EST 2009


http://bugzilla.novell.com/show_bug.cgi?id=565616

http://bugzilla.novell.com/show_bug.cgi?id=565616#c0


           Summary: InvalidCastException when storing a not IConvertible
                    value in a string datacolumn.
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 1.2.0
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
        ReportedBy: informatique.internet at fiducial.fr
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.1.5)
Gecko/20091109 Ubuntu/9.10 (karmic) Firefox/3.5

In MS.NET it's possible to store an "object" inside a "string" typed
datacolumn...
A .ToString() is called on the object

On Mono, it's done only if the object is IConvertible

Reproducible: Always

Steps to Reproduce:
1. try this test :
DataTable dt = new DataTable ();
dt.Columns.Add ("ID", typeof(string));
DataRow row = dt.NewRow ();
row["ID"] = Guid.NewGuid ();
2.
3.you could run the test with :
row["ID"] = new Object();
Actual Results:  
System.ArgumentException: Cannot cast from source type to destination type..
Couldn't store in Column named 'ID'. Expected type is String. --->
System.InvalidCastException: Cannot cast from source type to destination type.
at System.Data.Common.DataContainer.GetContainerData (System.Object value)
[0x0013b] in
/home/hfongarnand/mono/monostable/mcs/class/System.Data/System.Data.Common/DataContainer.cs:201
at System.Data.Common.StringDataContainer.SetValue (Int32 index, System.Object
value) [0x00000] in
/home/hfongarnand/mono/monostable/mcs/class/System.Data/System.Data.Common/DataContainer.cs:982
at System.Data.Common.DataContainer.set_Item (Int32 index, System.Object value)
[0x00039] in
/home/hfongarnand/mono/monostable/mcs/class/System.Data/System.Data.Common/DataContainer.cs:63
at System.Data.DataColumn.set_Item (Int32 index, System.Object value) [0x00011]
in
/home/hfongarnand/mono/monostable/mcs/class/System.Data/System.Data/DataColumn.cs:151
--- End of inner exception stack trace --- at System.Data.DataColumn.set_Item
(Int32 index, System.Object value) [0x00024] in
/home/hfongarnand/mono/monostable/mcs/class/System.Data/System.Data/DataColumn.cs:153
at System.Data.DataRow.set_Item (Int32 columnIndex, System.Object value)
[0x000b3] in
/home/hfongarnand/mono/monostable/mcs/class/System.Data/System.Data/DataRow.cs:192
at System.Data.DataRow.set_Item (System.String columnName, System.Object value)
[0x00039] in
/home/hfongarnand/mono/monostable/mcs/class/System.Data/System.Data/DataRow.cs:141 

Expected Results:  
It should store the result of the ToString() Method in the datacolumn

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list