为什么以及何时应该让Com Components对Com Components可见?

Luc*_*umb 4 c# com asp.net-mvc

我有一个Mvc应用程序,我有这个选项:

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
Run Code Online (Sandbox Code Playgroud)

我不知道这可以做什么,是一个安全设置?

何时选择ComVisible(false)和ComVisible(true)?

我搜索Com组件,了解它是什么,我找到了这个定义:

组件对象模型(COM)是Microsoft在1993年引入的软件组件的二进制接口标准.它用于在大量编程语言中实现进程间通信和动态对象创建.COM是其他几种Microsoft技术和框架的基础,包括OLE,OLE自动化,ActiveX,COM +,DCOM,Windows shell,DirectX,UMDF和Windows运行时.

这对我来说意味着,Com组件是一种在应用程序之间进行通信的方式,但我不确定我对这个定义的理解是否严格.

你能用简单的词语(例子)告诉我,为什么以及何时应该使ComVisible(true)?

Cee*_* it 7

当您需要将程序集中的公共方法和函数公开给其他非.NET编写的应用程序时,可以将ComVisible属性设置为true,然后可以使用Microsoft的COM(程序集绑定到组件的标准化接口)使用组件中的功能.运行.

进一步阅读:https://blogs.msdn.microsoft.com/cristib/2012/10/31/how-com-works-how-to-build-a-com-visible-dll-in-c-net-call -它从- VBA和选择最合适的-classinterface-autodispatch-autodual-part12

示例:https://richnewman.wordpress.com/2007/04/15/a-beginner%E2%80%99s-guide-to-calling-a-net-library-from-excel