1
votes

With the help of a few tutorials from Microsoft and others, I created a small Control-AddIn for Dynamics NAV 2016.

This AddIn works fine when it is placed in the client's addins-folder. I was asked to make the AddIn work on a server, so it doesn't have to be distributed to every user.

Microsoft gives no information on this whatsoever even though there are standard AddIns that work on server side.

Simply moving the AddIn-dll and recreating the references for the Add-In does not seem to work.

I tried various obscure ways to get this AddIn to be detected on the server side. The following procedure worked exactly once, but not again when I edited the C# code:

  • Remove Add-In from client AddIns-folder and AddIns-table
  • Move Add-In into server AddIn-folder and create new AddIns-table entry
  • Create a page using the Control-AddIn in a field and create a DotNet variable of the Control-AddIn class (with property RunOnClient = Yes), which is initialized in "OnInit". Nothing else.
  • Run CodeUnit 2, Run the new page (AddIn-dll is now copied to the NAV temp-folder)

But like I mentioned this only worked one time and since then the AddIn is never found. Does anyone know a certainly working method to get Control-Addins to run from server?

1

1 Answers

0
votes

So I ended up figuring it out myself and I find the answer, a little odd, but here it is in case anyone else has trouble with this:

  • Place your Add-In in the server's Add-Ins folder
  • Add a new entry for your control Add-In to the Control Add-Ins page
  • In the page that should use the Add-In you FIRST have to create a DotNet-variable of your Add-In's class. Initialize this variable in the OnInit function.
  • AFTER setting up the variable create the field for your Control Add-In and select the control Add-In in the properties.

It seems that first creating the variable is needed to have the Assembly copied into temp or something. Without it some functions of the Add-In may not be detected.

The initialization is also needed to make sure Add-Ins are copied to the client's temp folder before the control Add-In you want to display is initialized. Without this step the assembly won't be found.