Skip to Content
.NET Common Language Runtime Unleashed
book

.NET Common Language Runtime Unleashed

by Kevin Burton
April 2002
Intermediate to advanced content levelIntermediate to advanced
1024 pages
23h 26m
English
Sams
Content preview from .NET Common Language Runtime Unleashed

Late-Binding to a COM Component

It is possible to avoid using tlbimp if you are willing to give up some performance and use late binding. To use late binding, your component must implement IDispatch and preferably IProvideClassInfo to provide type information about your COM methods and properties. Listing 8.7 shows a simple example of using late binding. The full source to this sample is available in the LateBinding directory.

Listing 8.7. Late Binding to a COM Component
 String progId = "COMTypes.TypeTest"; Type t = Type.GetTypeFromProgID(progId); Object o = Activator.CreateInstance(t); t.InvokeMember("Name", BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance, null, o, new Object[] {"Testing"} , null, null, null); Object ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Customizing the Microsoft® .NET Framework Common Language Runtime

Customizing the Microsoft® .NET Framework Common Language Runtime

Steven Pratschner

Publisher Resources

ISBN: 0672321246Purchase book