[Mono-devel-list] DataSetHelper Class and Mono problems?

S Umadevi sUmadevi at novell.com
Thu Oct 14 23:40:54 EDT 2004


Hi Jon,
  Welcome to Mono!
  
I checked your sample code mentioned below, the code throws exception
even on MS.NET and the line that it is throwing the exception is
 return ((decimal)a + (decimal)b);
Which is valid..

There was a problem with the clone of dataset and datatable that I have
fixed yesterday, since your code is using clone, use the latest code
from CVS to get it working.

Regards
Uma



>>> "Jon Benson" <Jon at destra.com> 10/15/04 8:39 AM >>>
Hi folks,

My first time on the list so I should say I'm VERY new to Mono having
recently compiled the RPMS for RedHat Enterprise Linux and I'm now
trying to get some code ported from Windows and the MS framework.

I've tried to take some code I have running on Windows using the
DataSetHelper class by Microsoft which is available here:
http://www.codeaddict.com/download/datasethelper.cs.zip 

However I run in to a problem with one of the functions throwing an
exception under Mono.  I've created a bit of test code to reproduce
this
exception:
Unhandled Exception: System.InvalidCastException: Cannot cast from
source type to destination type.
in <0x00085> Test.TestClass:Add (object,object)
in <0x0004e> Test.TestClass:Main (string[])


I'm no expert at C# and only a beginner when it comes to Mono.  Can
anyone offer me some advice here?

Can I even achieve what I'm trying to do here under Mono?


Sample code to reproduce the exception:
using System;

namespace Test
{
   class TestClass
   {
      [STAThread]
      static void Main(string[] args)
      {
         int i1 = 34; int i2 = 8;

         int i3 = (int)((decimal)i1 + (decimal)i2);
         Console.WriteLine(i3.ToString());

         i3 = (int)(TestClass.Add(i1, i2));
         Console.WriteLine(i3.ToString());
      }

      private static object Add(object a, object b)
      {
          //Adds two values - if one is DBNull, then returns the other
          if (a is DBNull)
              return b;
          if (b is DBNull)
              return a;
          return ((decimal)a + (decimal)b);
      }
   }
}



Thanks, 
 
Jon Benson
Mail/DNS/Linux Administrator
OzHosting.com
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com 
http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list