Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Retrofitting a Class to Interoperate with COM
|
175
These attributes are used in conjunction with the previous two steps mentioned to
create and register the assembly’s classes. Several other COM interop attributes exist
in the FCL, but the ones mentioned here provide the most basic control over how
your assembly is viewed and used by COM clients.
Discussion
The Foo class, defined within the Chapter_Code namespace, shows how these attri-
butes are applied:
using System;
namespace Chapter_Code
{
public class Foo
{
public Foo( ) {}
private int state = 100;
InterfaceTypeAttribute Defines how an interface is exposed to COM clients. This attribute may be used only on
interfaces. Valid interface types are:
InterfaceIsDual
The interface will be exposed as a dual interface.
InterfaceIsIDispatch
The interface will be exposed as a dispinterface.
InterfaceIsIUnknown
The interface will be exposed as deriving from IUnknown.
If this attribute is not used, the interface will default to being exposed as a dual
interface.
ProgIdAttribute Force the ProgId of a class to a defined string. An automatically generated ProgId con-
sists of the namespace and type name. If your ProgId may exceed 39 characters (i.e.,
your namespace is equal to or greater than 39 characters), you should use this attribute
to manually set ...
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

C# Cookbook

C# Cookbook

Joe Mayo
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata