Does the code throwing it runtime exception run on server or on client?
A possible explanation is that your assembly has been deployed to client but not to AOS. Therefore compilation on client succeeds but execution on server fails.
Also, generating CIL can help if the failing code runs in CIL. If it runs in X++, don't waste time with regenerating CIL.