❔ Default behavior of ComVisible attribute

While updating a legacy .NET framework application to net6, I ran into a question where I was unable to find an answer for: What's the default behavior if I simply omit the ComVisible attribute from the AssemblyInfo? The doc says its default value is true but does that only apply when the attribute is set or will it also apply when I don't set the attribute at all? Does the compiler implicitly add anything like that?
5 Replies
realivanjxツ
realivanjxツ2y ago
The default is true, which indicates that the managed type is visible to COM. This attribute is not needed to make public managed assemblies and types visible; they are visible to COM by default. Only public types can be made visible. The attribute cannot be used to make an otherwise internal or protected type visible to COM or to make members of a nonvisible type visible.
reflectronic
reflectronic2y ago
i do believe the .NET SDK adds ComVisible(false) in a generated file it is pretty easy to check by opening the assembly in ILSpy okay, i lied, sorry. it does not
floribe2000
floribe2000OP2y ago
Thanks for the explanations. I somehow missed that part of the official docs
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server