Is there any point in specifying a Guid when using ComVisible(false)?

后端 未结 3 2142
庸人自扰
庸人自扰 2020-12-15 02:41

When you create a new C# project in Visual Studio, the generated AssemblyInfo.cs file includes an attribute specifying an assembly GUID. The comment above the attribute stat

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 03:25

    Having [assembly: ComVisible(false)] and [assembly: Guid("...")] at the same time makes perfect sense in certain cases. You start with an empty assembly and will perhaps want to expose something from it to COM. So you mark the assembly as not ComVisible and later mark the entities to expose as ComVisible. That is why the GUID exists by default.

    Regardless, if you really don't want to expose anything from your assembly to COM leave the "Register for COM interop" option unchecked in the project settings.

提交回复
热议问题