CA1017: Mark assemblies with ComVisibleAttribute


This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

TypeName MarkAssembliesWithComVisible
CheckId CA1017
Category Microsoft.Design
Breaking Change Non-breaking


An assembly does not have the System.Runtime.InteropServices.ComVisibleAttribute attribute applied to it.

Rule Description

The ComVisibleAttribute attribute determines how COM clients access managed code. Good design dictates that assemblies explicitly indicate COM visibility. COM visibility can be set for a whole assembly and then overridden for individual types and type members. If the attribute is not present, the contents of the assembly are visible to COM clients.

How to Fix Violations

To fix a violation of this rule, add the attribute to the assembly. If you do not want the assembly to be visible to COM clients, apply the attribute and set its value to false.

When to Suppress Warnings

Do not suppress a warning from this rule. If you want the assembly to be visible, apply the attribute and set its value to true.


The following example shows an assembly that has the ComVisibleAttribute attribute applied to prevent it from being visible to COM clients.

using namespace System;

[assembly: System::Runtime::InteropServices::ComVisible(false)];
namespace DesignLibrary {}
using System;

[assembly: System.Runtime.InteropServices.ComVisible(false)]
namespace DesignLibrary {}
Imports System

<Assembly: System.Runtime.InteropServices.ComVisible(False)>
Namespace DesignLibrary
End Namespace

See Also

Interoperating with Unmanaged Code Qualifying .NET Types for Interoperation