We encountered a similar error with a command line application running from Windows Task Scheduler. We had to check the 'Run with highest privileges' option on the General tab of Task properties.
This exception is thrown usually when you use a variable (or pass it to a function) with a member pointing to another read-only or non-existing (non-initialized) object.
It depends on your code but usually I solve this with the IClone interface.
In a debugger you can usually spot which variable is the culprit.
(in your case it might be needed to put a debug build on the server, and start a remote debugging session to see where it goes wrong)