It is now finished and time to share this with you all. The basic function Codeunit is used to handle the downloading and installing of the add-in. In the Add-on Setup Page I put an action to trigger the Add-ins validation.
This function will call the CheckAddins trigger on the Setup Table. There I have a simple code
IF NOT CANLOADTYPE(HardwareHubProxy) THEN
That will check if the add-in is installed and if not call a trigger in the add-ins function Codeunit to install the add-in. This works both for the client and server.
In this example I am installing the HardwareHubProxy.dll that is required on the server to use the Hardware Hub. Text002 is ‘ENU=Connection to the Advania Hardware Hub;ISL=Tenging við vélbúnaðargátt Advania’.
When installing the add-in I begin by downloading it into a Base64 string. This is always done on the server. The add-in is then saved to a temporary file, on the server for a server add-in and on the client for a client add-in.
Next I create a command file that is used to copy the temporary file to the add-ins folder. This command file is then executed. Before execution there is a check to see if the current user is able to write to the add-in directly. If so, then the add-in is copied to the add-ins folder and the process finishes.
If the service user is not able to write to the server add-ins folder the user will get a save-as dialog and is asked to copy the file to the server add-ins folder. In all my tests the server has been able to save the add-in without problems.
By default the running client will not be able to write the add-in to the client add-ins folder. If this is the case then a confirmation dialog will be prompted as the copy function is running in an elevated access mode.