I have same error for SP21 patch 10, patch 30 and patch 50. Bu i dont have no error for SP18 and SP19 all patch. I installed Codesys 3.5.21.50 and the Devices & Library package on a brand-new computer. After adding the DALI library, it gives a c0138 error. For some reason, SP21 doesn’t cause errors with the DLI library on some systems. I think this is due to hardware differences and the DLL files that are installed.
So, My advice to you is not to use SP21. Use SP19 instead.