Options

Cannot start NAV2018 NAS service on Windows 11 23H2

mariannicamariannica Member Posts: 3
edited 2024-01-16 in NAV Three Tier
Some computers that run latest version of windows 11 can't run NAS service anymore. The same settings work on other windows 11 based machines but some don't and I can't figure why. The error appears right at the start of this year on some machines that run build 22631.2861 of windows 11.
Tried removing the latest update and still the application can't run.

The error in event log is:
The Microsoft Dynamics NAV Server instance could not start because of an event publisher or subscriber error in relation to Codeunit 2. Try to recompile the object in the development environment to ensure the correct metadata is used.
    Compilation of assembly 'C:\ProgramData\Microsoft\Microsoft Dynamics NAV\110\Server\MicrosoftDynamicsNavServer$LS-NAV2018\assembly\Codeunit2_1.dll' failed. This can be caused by differences between binaries in your installation or your database. Ensure that all installation components are consistent and up to date. Error details: error CS1504: Source file 'c:\ProgramData\Microsoft\Microsoft Dynamics NAV\110\Server\MicrosoftDynamicsNavServer$LS-NAV2018\radsource\Codeunit2_1.cs' could not be opened ('Unspecified error ')

I tried manually compiling this "Codeunit2_1.cs" after trying to catch it before the service deletes it and the message tells me the files is in binary format not text file.
Any idea why this should happen?

Best Answer

  • Options
    mariannicamariannica Member Posts: 3
    Answer ✓
    Found the issue and resolved it.
    A policy from Windows Defender Application Control that was running in AUDIT mode was blocking the compiler from running with "/EnforceCodeIntegrity" flag. If removed was compiling fine, but we can't remove the flag inside NAS process.
    After removing the WDAC policy from the computer, the compiler runs fine and NAS service compiles successfully all the dlls required.
    So, don't try to add WDAC policy on computers where NAS service should run.

Answers

  • Options
    krikikriki Member, Moderator Posts: 9,089
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    KTA8KTA8 Member Posts: 391
    Being a dll and with that name looks like a custom dll. I would check for compatibilities
  • Options
    mariannicamariannica Member Posts: 3
    Found out that "Codeunit2_1.cs" is the same as "Codeunit2.cs" but the app creates a clone of it and then tries to compile it with csc.exe from .netframework.
    Where the service runs correctly, the files is compiled fine when run manually from cmd.
    csc.exe /t:library /utf8output /EnforceCodeIntegrity /R:"C:\Program Files\Microsoft Dynamics NAV\110\Service\Microsoft.Dynamics.Nav.Ncl.dll" /R:"C:\Program Files\Microsoft Dynamics NAV\110\Service\Microsoft.Dynamics.Nav.Types.dll" /R:"C:\Program Files\Microsoft Dynamics NAV\110\Service\Microsoft.Dynamics.Nav.Language.dll" /R:"System.Runtime.Serialization.dll" /out:"C:\ProgramData\Microsoft\Microsoft Dynamics NAV\110\Server\MicrosoftDynamicsNavServer$LS-NAV2018\assembly\Codeunit2_1.dll" /D:DEBUG /debug+ /optimize- /w:0  /checked+  "C:\ProgramData\Microsoft\Microsoft Dynamics NAV\110\Server\MicrosoftDynamicsNavServer$LS-NAV2018\radsource\Codeunit2_1.cs"
    Microsoft (R) Visual C# Compiler version 4.8.9032.0
    for C# 5
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
    
    

    On computers where the service can't be started, compiling the same file returns an error:
    csc.exe /t:library /utf8output /EnforceCodeIntegrity /R:"C:\Program Files\Microsoft Dynamics NAV\110\Service\Microsoft.Dynamics.Nav.Ncl.dll" /R:"C:\Program Files\Microsoft Dynamics NAV\110\Service\Microsoft.Dynamics.Nav.Types.dll" /R:"C:\Program Files\Microsoft Dynamics NAV\110\Service\Microsoft.Dynamics.Nav.Language.dll" /R:"System.Runtime.Serialization.dll" /out:"C:\ProgramData\Microsoft\Microsoft Dynamics NAV\110\Server\MicrosoftDynamicsNavServer$LS-NAV2018\assembly\Codeunit2_1.dll" /D:DEBUG /debug+ /optimize- /w:0  /checked+  "C:\ProgramData\Microsoft\Microsoft Dynamics NAV\110\Server\MicrosoftDynamicsNavServer$LS-NAV2018\radsource\Codeunit2_1.cs"
    Microsoft (R) Visual C# Compiler version 4.8.9032.0
    for C# 5
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
    
    error CS1504: Source file 'c:\ProgramData\Microsoft\Microsoft Dynamics
            NAV\110\Server\MicrosoftDynamicsNavServer$LS-NAV2018\radsource\Codeunit2_1.cs' could not be opened ('Unspecified
            error ')
    

    Same access writes are given to the files. Same csc.exe version on both computers. No idea what "Unspecified error" means.
  • Options
    mariannicamariannica Member Posts: 3
    Answer ✓
    Found the issue and resolved it.
    A policy from Windows Defender Application Control that was running in AUDIT mode was blocking the compiler from running with "/EnforceCodeIntegrity" flag. If removed was compiling fine, but we can't remove the flag inside NAS process.
    After removing the WDAC policy from the computer, the compiler runs fine and NAS service compiles successfully all the dlls required.
    So, don't try to add WDAC policy on computers where NAS service should run.
Sign In or Register to comment.