Results 1 to 3 of 3

Thread: [RESOLVED] Need help understanding COM Visibility Rules

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,437

    Resolved [RESOLVED] Need help understanding COM Visibility Rules

    I analyzed my source code in Visual Studio and I received too many warnings that say this:
    Code:
    Warning	CA1405	'DesktopWin.MenuColorTable' is marked ComVisible(true) but has the following 
    ComVisible(false) types in its object hierarchy: 'ProfessionalColorTable' Deskview	
    D:\Visual Studio Projects\Deskview\Deskview\DesktopWin.vb	412	Active
    I have a "tiny" bit of understanding about this, but mostly I just don't have a clue. Could someone tell me how to fix this?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: Need help understanding COM Visibility Rules

    It sounds like you are exposing a type to COM that inherits a type that is not exposed to COM. Presumably any of that vase functionality will not be accessible to the COM code. Did you read the documentation for the warning?

    https://docs.microsoft.com/en-us/vis...5?view=vs-2019

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,437

    Re: Need help understanding COM Visibility Rules

    Yes, I did read what the docs says about this, but I'm still working on how to understand it. I've been focusing mostly on how the docs say to fix the issue. Here is a small class I made that gets the warning...
    Code:
        Public Class MenuColorTable
            Inherits ProfessionalColorTable
    
            Public Sub New()
                MyBase.UseSystemColors = False
            End Sub
    
            Public Overrides ReadOnly Property MenuBorder As Color
                Get
                    Dim thisColor As Color = Color.FromArgb(52, 64, 85)
                    Return thisColor
                End Get
            End Property
        End Class
    This is how the docs say to fix the violation...
    To fix a violation of this rule, make the base types COM visible or the derived type COM invisible.

    Ok, I have just now found out how to fix the issue. In AssemblyInfo.vb, ComVisible was declared as
    Code:
    <Assembly: ComVisible(True)>
    I just changed it to:
    Code:
    <Assembly: ComVisible(False)>
    And every warning went away

    I guess I can chalk this up to growing pains... If I ever see the warning again, I know what to look for now.
    Thanks jmcilhinney for helping me to think about this. I really appreciate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width