Avoid static members in ComVisible types
TypeName |
AvoidStaticMembersInComVisibleTypes |
CheckId |
CA1407 |
Category |
Microsoft.Interoperability |
Breaking Change |
NonBreaking |
Cause
A type that is specifically marked as visible to COM contains a public static method.
Rule Description
COM does not support static methods.
This rule ignores property and event accessors, operator overloading methods or methods marked with the System.Runtime.InteropServices.ComRegisterFunctionAttribute attribute or the System.Runtime.InteropServices.ComUnregisterFunctionAttribute attribute.
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, change the design to use an instance method that provides the same functionality as the static method.
When to Exclude Warnings
It is safe to exclude a warning from this rule if a COM client does not need access to the functionality provided by the static method.
Related Rules
Mark assemblies with ComVisible
Avoid int64 arguments for VB6 clients
Avoid non-public fields in ComVisible value types