Peter Stephens wrote:
> So I made a wrapper object that implements IDisposable and then calls
> Marshal.ReleaseComObject(...) on Dispose().
I think it's nearly criminal (<grin>) that the .NET team didn't add
Dispose() support automatically on generated COM wrappers!
> // Properties
> public Object Target
> {
> get { return _obj; }
> set
> {
> lock(this)
> _obj = value;
> }
> }
Everything looks okay except this. Since this wrapper is meant to be a sort
of strong ownership over the object, I don't think it's a good idea to let
it be set (thus causing the old object to, presumably, go out of reference
without being cleaned up). Since you're going to be using this in a using
block (presumably), I would personally consider it logically inconsistent to
be swapping the object out underneath it.
Just my 2c. :)
Brad
--
Read my web log at http://www.quality.nu/dotnetguy/
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.