AL icon indicating copy to clipboard operation
AL copied to clipboard

Using dotnet components in Job Queue in on-premise

Open MatDDev opened this issue 8 years ago • 9 comments

- AL Extension Version: 
0.12.28462

Hello Guys,

I am trying to use some functions from FileMgt Codeunit (419), mostly to check if files exist on server, or to move them between folders. When running my functionality manually it works fine, but when I am trying to set up it as a job queue and run I do get an error:

Microsoft Dynamics NAV Server attempted to issue a client callback to create a DotNet object: System.IO.File (CodeUnit 419 File Management). Client callbacks are not supported on Microsoft Dynamics NAV Server.

Both target settings in app.json and on NAS are set to Internal.

I've searched multiple sources with the similar problem, but haven't found a solution. Did you guys encounter such error and maybe solved it? Thanks!

MatDDev avatar Oct 12 '18 09:10 MatDDev

When you say "running manually" does that mean Windows Client? And could you check in the Web Client as well? I would guess that you are calling something which triggers some client side .NET functionality. That would work in the Windows Client, but not in the Web Client or in the job queue

tfenster avatar Oct 12 '18 10:10 tfenster

I put actions on pages where user can run process manually, and yes it works on Windows client and yes it uses client side .net functionality.

Does it mean that .net functionality wont work in job queue at all? Is there any other solution to achieve it?

MatDDev avatar Oct 12 '18 10:10 MatDDev

Server side .net works AFAIK but client side .net won't. There is no client, so there is no "place" to run that client side functionality

tfenster avatar Oct 12 '18 10:10 tfenster

That's right, you cannot run client-side .NET in the job queue

StanislawStempin avatar Oct 12 '18 11:10 StanislawStempin

Did it work before the extensions 2.0, prior to NAV 2017-2018? Is there any other way to use function from FileMgt codeunit to check and manipulate files with code written in AL?

I am wondering what if I won't use job queue and instead use powershell script with Invoke-NAVCodeunit to run my functions. Will it crash?

MatDDev avatar Oct 12 '18 11:10 MatDDev

If you don't run in a Windows Client, then you can't use client side .net. If you are on NAV 2017/18 or bc on prem, you can use server side .net for file management

tfenster avatar Oct 12 '18 11:10 tfenster

This might be a dumb question, but how I am supposed to use server side .net?

@Edit Ok, maybe this is the issue. I am using a MoveFile function which uses ClientFileHelper dotnet variable which has set RunOnClient = Yes. I will try instead use ServerFileHelper variable to move the files.

MatDDev avatar Oct 12 '18 11:10 MatDDev

exactly. RunOnClient = Yes means it is client side. Otherwise it is server side.

tfenster avatar Oct 12 '18 13:10 tfenster

I've replaced function MoveFile which uses client side .net to CopyServerFile and DeleteServerFile which use server side .net functionality and it worked. Thanks @tfenster !

MatDDev avatar Oct 12 '18 14:10 MatDDev