Why is marking an assembly ComVisible(true) discouraged?

后端 未结 5 2065
日久生厌
日久生厌 2021-01-07 18:53

I have always marked my .NET assemblies as visible to COM with [assembly: ComVisible(true)], thinking that I never know when someone might need to call them fro

5条回答
  •  我在风中等你
    2021-01-07 19:39

    Marking the assembly not COM visible is very useful when you have a bunch of public classes inside that you don't want to expose to COM. Those classes could for example be proxy classes of a web serive your assembly consumes. Either you thoroughly mark each such class not COM visible or you just mark the assembly not COM visble and then mark each class to expose to COM. That's a much higher degree of control and less maintenance.

提交回复
热议问题