1
Vote

Null Reference Exception in Gpgapi.dll

description

We were having random issues with GpgAPI 1.50 and decrypting files. Once we got the source code it seemed that the culprit was in the Set() call in the delegate added to the process exited event:
            _process.Exited += delegate(Object sender, EventArgs args)
            {
                _processExited = true;
                _exitedEventWait.Set();
            };
Randomly _exitedEventWait would be null and an exception would be thrown. I tried to fully interpret the problem but the only way to fix it was to check for null first. With the change below we no longer have any issues:
            _process.Exited += delegate(Object sender, EventArgs args)
            {
                _processExited = true;
                if (_exitedEventWait != null) _exitedEventWait.Set();
            };

comments