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 ')
Answers
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Where the service runs correctly, the files is compiled fine when run manually from cmd.
On computers where the service can't be started, compiling the same file returns an error:
Same access writes are given to the files. Same csc.exe version on both computers. No idea what "Unspecified error" means.
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.