Confused about data types in COM, VFP and C#
I'm about to migrate from VFP to C#, but I'm a bit confused about the data
types. I know that I can use the CLSCompliant-attribute to make sure that
my data types are valid COM-types. But let's take the following few
methods:
[assembly: CLSCompliant(true)]
namespace SampleNSpace {
[ComVisible(true)]
[Guid("111B0014-EB08-4093-A818-1D11EB4C489D")]
public class AnyClass {
public int GetAnyInt() { return int.maxValue; }
public long GetAnyLong() { return long.maxValue; }
public decimal GetAnyDecimal() { return decimal.maxValue; }
public double GetAnyDouble() { return double.maxValue; }
}
}
Alright, calling GetAnyInt() works as expected and the return value is
exposed as long (as described in
http://msdn.microsoft.com/en-us/library/sak564ww.aspx). But calling
GetAnyLong() and GetAnyDouble() doesn't work and I currently don't know
why. I'm always getting "Function argument value, type, or count is
invalid.". I first thought, that the reason is that double and long are 8
byte/64 bits long (because max exact number in VFP is 2^53), but calling
GetAnyDecimal() works without any error and decimal is 8 byte longer (128
bit overall). Anyone know what's the reason why DECIMAL works and
double/long doesn't?Thanks for any thoughts!
No comments:
Post a Comment