NAV2009 R2 - "Callback functions are not allowed" without UI

Sebi64Sebi64 Member Posts: 13
edited 2014-05-16 in NAV Three Tier
Hello,

I have a codeunit with a function that unzip some datas.
I use a .NET dll of my own based on SharpZLib to do that :
PROCEDURE UnzipInputXml@1000000006(inputXml@1000000005 : BigText;VAR outputXml@1000000002 : BigText);
VAR
  zipLib@1000000000 : DotNet "'ZipLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f578592a428333cd'.ZipLib.Zip" RUNONCLIENT;
BEGIN
  outputXml.ADDTEXT(zipLib.UnzipToStream(inputXml));
END;

When i use this function in RTC, all is working fine.
But I need to do this each night and as I'm using some .net code i can't do it with the standard job queue.
So my idea was to use dynamics web service.

But now i have this error : Callback functions are not allowed.
I know that when using web service the C/AL must not contains code like CONFIRM, ERROR,... And that's the case I don't have any UI related functions but i still have this error when my dll is called.

Does someone already had this error?
Do you have any idea of what i can do?

Answers

  • kinekine Member Posts: 12,562
    Looks like the DLL itself is displaying some progressbar etc. Why to not use the standard Windows scheduler to unpack what you need? You do not need to use NAV for that.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Sebi64Sebi64 Member Posts: 13
    Hello, thanks for your answer.

    There is no progressbar or any UI related stuff that appears when i launch the codeunit from the RTC...
    The data are stored in the NAV database as BLOB and each night I have more than 1000 lines to unpack and parse (the zip contains some XML that i have to add to some tables).
    So it looked to me easier to do that in NAV.

    Yesterday I also tried to launch my code with a report and from the command line like that :
    dynamicsnav://navSrv/navDb/companyName/runreport?report=xxxxx
    

    But then i have this message :
    Microsoft Dynamics NAV Security Notice
    You are about to connect to 'navDb on server 'navSrv', which is not your current default connection setting.

    This can create a security risk.
    Do you want to continue?
    Yes No

    As i would like to launch this line from task scheduler, i'm stuck...

    What was your idea with the windows scheduler?
  • ichladilichladil Member Posts: 68
    Hello,

    The error message is a bit misleading in this case.

    When running code from Web Service, the code must not use the .NET variables with RUNONCLIENT as that would mean "client callback". Therefore modify it so that the zip library is on the service tier and then it should work fine.

    Regards,
    Igor
  • kinekine Member Posts: 12,562
    Regarding the Windows scheduler - just thought that you need to unpack some specific file each time. It means, creating cmd file which will do that for you, but if you have the data which files you need unpack in DB, it is not possible...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Sebi64Sebi64 Member Posts: 13
    Yes you're right, I have to copy my dll on the service tiers!

    But...
    If I keep RunOnClient to yes and copy my .net dll to the service tier I have the same error message (Callback functions are not allowed).

    If I switch RunOnClient to False then I have to copy my .net dll to the NAV server isn't it? Then i have this error message :
    Exception lors de l'appel de « ParseXml » avec « 0 » argument(s) : « Ce message est destiné aux programmeurs C/AL : Impossible 
    de créer une instance de l'objet .Net : assembly ZipLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f5785
    92a428333cd, type ZipLib.Zip. »
    Au niveau de ligne : 1 Caractère : 15
    + $test.ParseXml <<<< ()
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException
    
    Which means : This message is for C/AL programmers : could not create an instance of the .net assembly...

    I should missed something...
  • Sebi64Sebi64 Member Posts: 13
    kine wrote:
    Regarding the Windows scheduler - just thought that you need to unpack some specific file each time. It means, creating cmd file which will do that for you, but if you have the data which files you need unpack in DB, it is not possible...
    yes, that's what I thought...
  • ichladilichladil Member Posts: 68
    Hi,

    Regarding the error with RunOnClient = No.

    That really sounds like the library or some of its dependencies are not accessible from the service tier. Your DLL should be in Add-Ins directory of ServiceTier. Any dependencies like SharpZLib should be there or in global assembly cache as well.

    As you said the code works from RTC, I assume that your function is static and so it doesn't require instance creation first (by using constructor). In that case I would be really looking at why the DLL has not been found ... I would e.g. restart the services, double check that I have placed correct DLLs into correct service tier folders, etc.

    Regards,
    Igor
  • Sebi64Sebi64 Member Posts: 13
    Thanks you very much for your help ichladil and kine.

    Now it's ok.
    ichladil you were right, my error was that i had copied the addin(and their dependencies) in the wrong folder.
    With RunOnClient to False we have to copy the addin in the NAV Server (serverTier) and in the NAV Web server(serviceTier, if it's different from the server and if you use some ws).
    I did that before but not in the good folder.
    There is some folders for each database installation.

    On the serverTier :
    \Classic\Add-ins
    \RoleTailored Client\Add-ins
    \NavDatabaseXXX\Add-ins -->Add Addins here
    \NavDatabaseYYY\Add-ins -->Add Addins here
    \Service\Add-ins

    On the serviceTier :
    \NavDatabaseXXX\Add-ins -->Add Addins here
    \NavDatabaseYYY\Add-ins -->Add Addins here
    \Service\Add-ins

    děkuji!
Sign In or Register to comment.