Solved! Go to Solution.
For some reason, your statement is leading me to believe that you are releasing an object, then trying to do a method call on that object, but first checking whether the object you released is null, otherwise calling that method on a released object without first re-assigning that released object the value of null is giving you the exception. What do you expect? If you were in Java, assigning an object reference to null would still give you an exception when you tried calling a method on that object.
I still don't understand why you are trying to call a method on an object after you've released it. Can anyone explain that to me? I would really like to understand why you are trying to do this.
The exception is not caused by calling a method of that released COM object, but caused by releasing it again with my generic releasing method... it use "if (obj is IEnumerable)" to check the interface it supports. Because it is already released, the checking will fail in the second call of the releasing method.
Now I decide to resolve this issue by coding carefully, not to release the same COM object twice, even though the logic will be a bit more comoplicated.