SafeCOMWrapper - Managed Disposable Strongly Typed safe wrapper to late bound COM - The Code Project - C# Programming
SafeCOMWrapper - Managed Disposable Strongly Typed safe wrapper to late bound COM - The Code Project - C# Programming: "There are several problems using COM from .NET:
You cannot implement the Dispose pattern by utilizing the 'using' block in order to safely dispose COM references.
You cannot guaranty COM references are finalized. There's no way to implement '~Destructor()' for COM references.
COM reference is not released when a call to Marshal.ReleaseComObject is skipped due to an Exception.
When you 'Add Reference...' to a COM library, the reference is version specific. So, if you add a reference to the Office 2003 COM library, it does not work properly when deployed to Office 2000.
The only solution to version independent COM is to use Late Bound operations but you miss all the features of a strongly typed language.
Let's solve all these problems. We want to use a Managed strongly typed approach to Late Bound COM operations and also utilize the Dispose pattern on COM objects. The solution proposed here works for any COM object which can be Microsoft Office COM libraries, IE & DHTML objects and even your own COM objects. You should use this approach whenever you are dealing with any type of COM library.
Before going to the solution, let's learn a bit of background on RealProxy and method interception."


0 Comments:
Post a Comment
<< Home