Using Late Bound COM Objects
(Page 1 of 6 )
There are different methods available for invoking COM objects at runtime in .NET, including late binding. In this article Beth from the Wrox team will walk us through them, providing examples for each.
Editor's Note: This article's code has been updated to work with the final release of the .Net framework.
This article will describe how to late bind to COM objects in .NET. Interoperability with COM objects has been well-integrated into the .NET runtime. Indeed, early binding is quite straightforward and has already been covered quite well in Kaushal Sanghavi's articles on COM(+) interoperability (see reference list at the end of this article). Judging by the postings in the .NET newsgroups, however, there appears to be some lingering confusion about how to bind to COM objects at runtime. This article will discuss the different methods available for invoking COM objects at runtime. After a brief review of late binding (and why it should sometimes be avoided), we will walk through three different invocation scenarios and explore the appropriate C# syntax to use. We will end with a brief look at the relative performance of each method.
Prerequisites Our discussion assumes you understand the basic concepts of COM interoperability in .NET. If you are just getting up to speed on the topic, see the list of references at the end of this article. In particular, you should understand what a Runtime Callable Wrapper is, and how one is generated.
Next: Introductory Concepts >>
More C# Articles
More By Wrox Team