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

Jon Benson Jon at destra.com
Thu Oct 14 23:09:00 EDT 2004

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:

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
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
      static void Main(string[] args)
         int i1 = 34; int i2 = 8;

         int i3 = (int)((decimal)i1 + (decimal)i2);

         i3 = (int)(TestClass.Add(i1, i2));

      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);

Jon Benson
Mail/DNS/Linux Administrator

More information about the Mono-devel-list mailing list