Decimal data type and Automation in Role Tailored Client

Nav_NoobNav_Noob Member Posts: 25
edited 2009-05-18 in NAV Three Tier
Hello,
I have a .NET DLL which exposes some properties as COM. For example:

public decimal Amount
{
[return: MarshalAs(UnmanagedType.Currency)]
get{ return this.amountField; }
set{ this.amountField = value; }
}

I have a decimal type in NAV which I pass to the Amount property. For example:

"Automation Line".Amount := "Decimal Var";

This works fine in the classic client but when the code runs in the role tailored client, I get the following error:

This message is for C/AL programmers: The call to member Amount failed: Method
'My.Namespace.Line.Amount' not found..

All non-decimal types work fine in the role tailored client. One work-around might be to extend the DLL by adding a method which takes the line amount as a string and have the DLL convert the string to decimal, but I'd rather not extend the DLL if at all possible. Does anyone have any idea what could be going wrong or a better solution?

Thanks,
Adam

Comments

  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    I think your problem is the ReturnAs() - the RTC runs all your code in Managed code - you should try a couple of different return type options.
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • Nav_NoobNav_Noob Member Posts: 25
    freddy.dk wrote:
    I think your problem is the ReturnAs() - the RTC runs all your code in Managed code - you should try a couple of different return type options.

    Hi Freddy,
    Thanks for your response. I'm not exactly sure what you're saying. Are you saying to try a different return type in my DLL? Maybe I should try marshaling my decimal types as something other than UnmanagedType.Currency? Or are you saying there is something I can do on the NAV side of things? I wasn't quite sure what you meant by ReturnAs(). Thanks again for your input and if you can elaborate a little bit more on the different return type options that you mentioned, it would be a great help.

    Thanks,
    Adam
  • kinekine Member Posts: 12,562
    Manage it as decimal, not as currency, because it IS decimal and not currency in NAV.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Nav_NoobNav_Noob Member Posts: 25
    kine wrote:
    Manage it as decimal, not as currency, because it IS decimal and not currency in NAV.
    Thanks for the suggestion, I'll give it a try. The NAV help on MSDN says to use the C/AL Decimal data type with the COM Currency data type (http://msdn.microsoft.com/en-us/library/dd301064.aspx) but at this point, I'll try anything. Thanks again, I'll report back on my results.
Sign In or Register to comment.