COM Interop
assembly visibility
.NET programming
software interoperability
COM registration

Register for COM Interop vs Make assembly COM visible

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Register for COM Interop and ComVisible sound similar, but they solve different problems. One controls whether types are exposed to COM at the code level, and the other controls whether the built assembly is registered on a machine so COM clients can find it.

ComVisible Controls Exposure

ComVisible is a .NET attribute. It decides whether an assembly, class, interface, or member should be visible to COM clients.

A common pattern is to hide everything by default and opt in only the types you actually want to expose.

csharp
1using System.Runtime.InteropServices;
2
3[assembly: ComVisible(false)]
4
5[ComVisible(true)]
6[Guid("D9E4D9B7-18D9-4E87-A0D5-45EC830A7F5A")]
7public interface ICalculator
8{
9    int Add(int a, int b);
10}
11
12[ComVisible(true)]
13[Guid("2B4AF1C3-2A74-4756-A265-CC12F1EE8D6E")]
14[ClassInterface(ClassInterfaceType.None)]
15public class Calculator : ICalculator
16{
17    public int Add(int a, int b) => a + b;
18}

Without COM visibility, the type is not intended for COM consumption even if the assembly is otherwise registered.

Register for COM Interop Controls Registration

Register for COM Interop is a build setting in Visual Studio. When enabled, Visual Studio registers the built assembly for COM on the local machine after a successful build.

That registration step writes information such as CLSIDs and ProgIDs into the Windows registry so COM clients can instantiate the component.

In other words:

  • 'ComVisible answers: should COM see this type'
  • registration answers: can COM locate and activate this assembly on this machine

You can think of visibility as exposure and registration as discoverability.

One Does Not Replace The Other

These settings are related, but they are not substitutes.

If a class is ComVisible(false), registering the assembly does not make that class usable from COM.

If a class is ComVisible(true) but the assembly is not registered, a COM client may still fail to create it because the runtime has no registration data to resolve the component.

That is why code-level exposure and machine-level registration must both be considered.

Registration Can Be Done Without Visual Studio

Visual Studio is not the only way to register a COM-visible assembly. You can also do it explicitly during deployment or local testing.

powershell
regasm MyLibrary.dll /codebase /tlb:MyLibrary.tlb

This is often preferable in controlled deployment pipelines because it is explicit and repeatable. The Visual Studio checkbox is mainly a developer convenience for local testing.

When To Use Each Option

Use ComVisible when designing the public interop surface of your assembly. This is part of API design.

Use Register for COM Interop when you need the built assembly automatically registered on your development machine after build.

For production deployment, many teams avoid relying on the Visual Studio build checkbox and instead use an installer, registration script, or another explicit deployment step.

Prefer Explicit Interfaces For COM

If you are exposing .NET types to COM, avoid relying on automatically generated class interfaces. Define explicit interfaces and keep GUIDs stable.

That reduces versioning surprises and gives you tighter control over what COM consumers see.

csharp
1[ComVisible(true)]
2[InterfaceType(ComInterfaceType.InterfaceIsDual)]
3public interface ICalculator
4{
5    int Add(int a, int b);
6}

This is separate from registration, but it is usually where robust COM interop design succeeds or fails.

Common Pitfalls

The most common mistake is assuming the Visual Studio registration checkbox makes an assembly COM-visible by itself. It does not.

Another mistake is exposing too much by setting the whole assembly to ComVisible(true) and never narrowing the surface area.

Developers also run into environment-specific bugs because Register for COM Interop affects the local development machine, not necessarily the machines where the software will finally run.

Finally, COM registration issues are often mistaken for visibility issues, and vice versa. Check both dimensions separately.

Summary

  • 'ComVisible controls which .NET types are exposed to COM.'
  • 'Register for COM Interop registers the assembly on a machine.'
  • Visibility and registration are complementary, not interchangeable.
  • Use explicit interfaces and stable GUIDs for cleaner COM interop.
  • Prefer explicit deployment-time registration over relying only on a local IDE checkbox.

Related reading
Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.