Fix unhandled exception while calling CoRegister