[2005] Assembly Threading Apartments
Hi Guys,
I am creating a class to wrap some Excel functionality. My class exposes the IDisposable interface in order to kill Excel once I have finished with it. When I explicitly call my Dispose() method everything is fine. If I leave it up to the framework I get error: "COM object that has been separated from its underlying RCW cannot be used."
When I call Dispose() from my WindowsForms project its is in STA mode; everything is fine. If the framework calls Dispose() the threading state is MTA.
How would I go about ensuring the framework calls Dispose() on the same thread as it was created?
Thanks Guys,
Matt
Re: [2005] Assembly Threading Apartments
Also, I plan to compile this into a class library. So I cant control what threading state the calling assembly with be in.
Maybe I have to create my own thread within the class and perform all operations there??