Com visible types should be creatable

TypeName

ComVisibleTypesShouldBeCreatable

CheckId

CA1409

Category

Microsoft.Interoperability

Breaking Change

NonBreaking

Cause

A reference type that is specifically marked as visible to COM contains a public parameterized constructor but does not contain a public default (parameterless) constructor.

Rule Description

A type without a public default constructor is not creatable by COM clients. However, the type is still accessible to COM clients if another means is available to create the type and pass it to the client, for example, through the return value of a method call.

The rule ignores types derived from System.Delegate.

By default, the following are visible to COM: assemblies, public types, public instance members in public types, and all members of public value types.

How to Fix Violations

To fix a violation of this rule, add a public default constructor or remove the System.Runtime.InteropServices.ComVisibleAttribute from the type.

When to Exclude Warnings

It is safe to exclude a warning from this rule if other ways are provided to create and pass the object to the COM client.

Mark assemblies with ComVisible

See Also

Concepts

Qualifying .NET Types for Interoperation

Other Resources

Interoperating with Unmanaged Code