다음을 통해 공유


Serviced Component Programming Guidelines

Although the .NET Framework extends many of the programming features introduced by COM, and although the common language runtime provides simplified access across the interoperation boundary, a COM client must adhere to the restrictions of its programming model. These restrictions can affect how and when you use the extensive features available to .NET Framework components. Therefore, you should consider who will use your .NET Framework component before you build it. Your early efforts to identify whether callers are COM-based can save you substantial time in the future.

Use the considerations in following table as guidelines for writing a .NET Framework component based on the type of caller.

Expected caller Considerations
.NET Framework clients only No special considerations.
.NET Framework and COM clients Same as the considerations listed below for COM clients only.
COM clients only Avoid using parameterized constructors.

Avoid using static methods.

Define event-source interfaces in managed code.

Include HRESULTs in user-defined exceptions.

Supply GUIDs for types that require them.

Expect inheritance differences.