.NET Decimal -> COM -> VT_DECIMAL -> Unknown
wakestar
Member Posts: 207
Hi there
I wrote a .NET assembly which has a COM Interface so I can call it from NAV.
I noticed that .NET decimal type gets marshalled to VT_DECIMAL... but the poor NAV classic client doesn't know what VT_DECIMAL is (VT_UNKNOWN).
According to the help...the NAV type Decimal is mapped to VT_Currency and...
So my question is:
is there a better way than marshalling the .NET Decimal type to VT_Currency?
Since I'm using my .NET assembly also in the newer versions of NAV with .NET Interop ... I want to keep the decimal datatype in .NET... since that works fine.
Anyone?
I wrote a .NET assembly which has a COM Interface so I can call it from NAV.
I noticed that .NET decimal type gets marshalled to VT_DECIMAL... but the poor NAV classic client doesn't know what VT_DECIMAL is (VT_UNKNOWN).
According to the help...the NAV type Decimal is mapped to VT_Currency and...
The CURRENCY type in COM is a special data type with a fixed point, which has 15 digits to the left of the point and 4 to the right. You should note that the Decimal type in C/AL does not have a fixed point and can have a total of 18 digits. This could possibly lead to some rounding being performed when a Decimal number is passed to a method that expects a CURRENCY, the server manipulates that number and returns it as a CURRENCY. No matter how many digits the original Decimal had to the right of the decimal point, the returned CURRENCY will have no more than 4 digits.
So my question is:
is there a better way than marshalling the .NET Decimal type to VT_Currency?
Since I'm using my .NET assembly also in the newer versions of NAV with .NET Interop ... I want to keep the decimal datatype in .NET... since that works fine.
Anyone?
0
Answers
-
try float or double data type instead.best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/0 -
Thanks! float seems fine.
May I ask how you handle DateTime? It seems like the time of datetime is lost when marshalled to VT_DATE0 -
you could convert the datetime value to double using DateTime.ToOADate.
follow http://stackoverflow.com/questions/16262007/datetime-tooadate-time-only
you can then convert the double value back to a datetime value.best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/0 -
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
