Dynamically loading assemblies at runtime

  • Post comments:7 Comments
  • Reading time:7 mins read

When you spend more time in C# than C/AL, and you still tell yourself and the world around you that you are developing for NAV, then this post is for you.

I already wrote a three-article series about “DLL hell” and how to resolve it, and in my last post in the series (https://vjeko.com/sorting-out-the-dll-hell-part-3-the-code) I delivered some code that help you take control of your .NET assemblies.

This time, I am delivering an updated solution, one that solves all the problems others, and myself, have encountered in the meantime.

So, fasten the seatbelt, and let’s embark on another .NET interoperability black belt ride.

(more…)

Continue ReadingDynamically loading assemblies at runtime

Getting out of the DateTime mess, or how to get Utc DateTime in C/AL

  • Post comments:13 Comments
  • Reading time:5 mins read

Today at work I was trying to untangle one big bowl of spaghetti called DateTime. It’s the C/AL DateTime I am talking about, not System.DateTime from .NET.

The problem with C/AL DateTime is that no matter what you do it’s, according to documentation, “always displayed as local time”.

Another problem with C/AL DateTime is that C/AL is a bit rude when it comes to System.DateTime: whenever C/AL compiler (or runtime) encounters a value of System.DateTime it’s automatically converted to C/AL DateTime.

When you combine those two problems, you get the following problem: even though System.DateTime is perfectly capable of handling time in both UTC or local kind, C/AL isn’t.

To prove this point, just run this:

MESSAGE(‘Current local time: %1\Current UTC time: %2’,SystemDateTime.Now,SystemDateTime.UtcNow);

It will show this:

image

And I am currently sitting in a UTC+1 time zone, mind you.

(more…)

Continue ReadingGetting out of the DateTime mess, or how to get Utc DateTime in C/AL

Deploying from Visual Studio, update

  • Post comments:1 Comment
  • Reading time:3 mins read

A few days ago I have published my PowerShell script that streamlines and automates deployment of control add-ins from Visual Studio. Over the past couple of days I have improved it a little bit, and fixed a few bugs, so here’s an updated version that is more resilient to your project structure, produces resource zips that NST not only extracts, but actually understands, and does a little more.

(more…)

Continue ReadingDeploying from Visual Studio, update

Out-of-transaction database writes

  • Post comments:7 Comments
  • Reading time:4 mins read

Ancient wisdom goes that you cannot have more than one write transaction going on at the same time in a single session in NAV.

This is absolutely true, in and out.

Some features, like Activity Log, will leave you wanting to be able to write to the database outside of the normally running transaction.

Wouldn’t it just be beautiful if you could:

  • Write to the database, and then persist the change to the database even if an error happens during the transaction? (without cough! TryFunction, cough! cough!);
  • Not cause any locks to remain at the target table for any longer than it takes to do the write itself, without having to call COMMIT on your “regular” transaction; and
  • Not use temporary tables, because a system error (however unlikely) could cause the data to not be persisted if crash happens before temporary table is flushed to the physical one.

Well, in fact, you can do this.

(more…)

Continue ReadingOut-of-transaction database writes

Sorting out the DLL hell, Part 3: The Code

  • Post comments:58 Comments
  • Reading time:16 mins read

[Update, February 8, 2016: there is a new version of code from this post. Please check https://vjeko.com/dynamically-loading-assemblies-at-runtime]

Okay here we go. In this post I deliver the promised code that handles automatic deployment of all your assemblies to client and server, as needed.

For any of you who haven’t read the last two posts, I am talking about automatically deploying .NET assemblies to clients and server, from the database, on demand, at runtime.

This will be heavy on code, so fasten your seatbelt and brace for impact.

(more…)

Continue ReadingSorting out the DLL hell, Part 3: The Code