NAVR2 Developer Day (Part 2) - .Net interoperability

This is the second part of my blog posts on de Nav 2009 R2 developer day. In this post you can find an overview of the new .Net features that will appear in NAV 2009 R2. It's just a quick report, I will be getting deeper into this on a later time.

Key Value Add

-        Allows C/AL developers to invoke the vast number of existing .NET based API’s

-        Reinforces the strength of the NAV 2009 Platform

-        Safer, easier and just as fast as COM

-        Streamlined developer experience

DotNet Variables in C/AL

Demo: Example with “System.Math”

Net datatype “DotNet”, F6 will open the .Net type list. (Just like Automation)

We have access to the full .Net Framework now!

Methods, properties and constructors can be found via the C/AL Symbol Menu.

Warning: Can only be run from the NAV server or RTC client! Not from C/Side!

-        DotNet Variables may be defined from
-             Types (classes)
-             Interfaces
-             Structs
-             Enums

-        Static versus Instance types

Creating and considerations when using .Net type variables

-        Instance types need a constructor
-             MyVariable := MyVariable.ctor();

-        Static will be shared across client sessions

-        NAV scoping rules apply
- Local variables go out of scope when method completes

-        Use NAV types for C/AL code mainly

-        Types that implement System.Array can be looped over

Don’t refactor your current application! Use .Net only when the type is right.

.Net should only be used if you really need it.

Use NAV types in C/AL, you are not supposed to use .Net types.  

Client side .Net types

-        .Net variables have RunOnCLient property

-        Default is false, performance is much better when running on the server

-        When running on client, a server-side proxy forwards all calls to the client

-        Can show UI

THIS IS NOT THE SAME AS CLIENT EXTENSIBILITY!!

Deployment overview

-        .Net assemblies must be deployed to
- The C/Side client used for development
- The tier where the .Net interop type is used

-        The assembly should be placed in de “Add-ins” folder

-        Assemblies in de GAC (Global Assemby Cache) need no deployment

(More) Secure Deployment

-        Client warning will show for first use of a .Net assembly

-        Want to avoid the dialogs? Use a secure server!

-        Register server with SPN and use SPN based client connection. SPN connected clients do not show warning.

Custom components

A couple of examples that use custom components where shown during the session.

-        Using “System.Diagnostics.Process” and “mscorlib.System.Array” to get a list of processes

-        Second example that uses an enum to transform numbers into names of colors and back.

-        A component to open your cd-tray
Constructor example: “CD := cd.CDTray(); (in C# “CD = new cd.CDTray()”

There will be development documentation for using .Net with NAV on the DVD.

You can’t use events with .Net in NAV2009 R2. That will come in NAV7.

----

So just a quick, preview of what is coming up in december. :)

So far, I like the new features a lot! Great work MS.

Related
Recommended