public void Dispose() { if (dispatcher == null) { // This happens exclusively in 32-bit .NET environment // after an IndigoObject constructor throws an exception. // In fact, the object is not created in this case, // but for some reason the .NET VM disposes it, despite it // has not been initialized. return; } if (self >= 0) { // Check that the session is still alive // (.NET has no problem disposing referenced // objects before the objects that reference to them) if (dispatcher.getSID() >= 0) { dispatcher.setSessionID(); dispatcher.free(self); self = -1; } } }