❔ 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
floribe20002y 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
More Posts
❔ Is there any overview of useful attributes and how to use them?E.g. [Obsolete] or for example where a method is allowed to be used and so on. Basically basic attri❔ Newtonsoft, count nested propertiesSome time ago I had a nice chat in here where we found a solution to a problem. Namely counting all list that holds 2 values eachI want to have a way to store a dynamic amount of data, where each entry holds a string and an int. ❔ How to close a process's handle?Hey folks, I'm trying to automate something that I've been doing manually through Process Explorer -❔ ObjectListView showing blank rowsHi all. I'm new to C# and making VSTO addins, please bare with me! I'm using the add-in control O❔ NullReferenceException Object reference not set to an instance of an object Billboard.UpdateHello, my name is Zorphix and I'm not so smart at C#. And I'm currently trying to add a billboard sc❔ Blazor Hosted - Client datatable with large datasetI have a table component (using MudBlazor) which accesses the server-side API endpoint and pulls (cu❔ How do I cycle through different observable collections within the same collection view?My current plan is to do something like: ``` List <ObservableCollection<TodoItem>> allTodoItems✅ I'm trying to understand WPF's source code. What is a WeakReferenceWeakReference is a class that probably has applications other than in WPF (in particular, I'm trying❔ Shortcut for selecting multiple lines on windowsHi, I want to select only lines 146, 150 and 154 in my project in order to copy them, is there a sho