Don’t worry about DotNet version in C/AL

When using DotNet data type in NAV C/AL we normally lookup a sub type to use.  When we do the result can be something like

Newtonsoft.Json.Linq.JObject.'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

Then, what will happen when moving this code from NAV 2016 to NAV 2017 and NAV 2018.  The Newtonsoft.Json version is not the same and we will get a compile error!

Just remove the version information from the sub type information.

Newtonsoft.Json.Linq.JObject.'Newtonsoft.Json'

And NAV will find the matching Newtonsoft.Json library you have installed and use it.

This should work for all our DotNet variables.

5 Replies to “Don’t worry about DotNet version in C/AL”

  1. Hi Gunnar,
    it seems that this only works for libraries from the Add-In-directory. When I try to do this with something from the .NET Framework it won’t work; e.g.:

    System.Net.FtpWebRequest.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′
    System.Net.FtpWebRequest.’System’

    The second variant will throw an error Could not load type ‘System.Net.FtpWebRequest.’System”. When I try the same with something from the Add-In-library it works fine.

    Just wanted to leave it here, in case someone else stumbles upon this ?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.