none
CLS compliant warning using UserControl RRS feed

  • Question

  •  

    Hi,
    I’ve created an userControl and I added in myProject


    Dim UserControl1 As New MyUserControl

    I add a new class and inside it, a shared method with parameter of the same type of MyUserControl

    Public Class MyClass

        Public Shared sub Do (ByVal UControl As MyUserControl)
               ' code

        End sub
    End class

    In the form I call the method Do

    MyClass.Do(UserControl1)

     

    Building the project I get the CLS compliant warning: the type of parametres UControl is not compliance with CLS.
    The same thing I can find with the green
    underlying in parametres UControl in method Do.

    Do you know the answer?

    Thanks,
    Mauro

    Monday, February 25, 2008 10:20 AM

Answers

  • Something in your UControl class probably is not CLS Compliant.  You can add the [System.CLSCompliant(false)] attribute to the class or method to remove this error.  Or just remove the [assembly: System.CLSCompliant(true)] attribute from assembly.info. 

    If you actually want to fix this, in your code for UControl add [assembly: System.CLSCompliant(true)] to the assembly.info file and make sure you use all CLSCompliant types.
    Monday, February 25, 2008 12:29 PM
  • Hi Dan,
    I did what you said to me.

    If I add to the class the attribute
    <CLSCompliant(false)> to the class who defines the user control the CLS warning still remains.

    If I add to the method:

    <CLSCompliant(false)> _

    MyClass.Do(UserControl1)
    UserControl1 ends to be green underliyng for the warning.

     

    I checked my code in UserControl to find what goes wrong for the CLS compliant but I’m not able to find the reason.
    However warnings disappear only as I’ve written, when I add the attribute in the form.

    Thanks and regards,
    Mauro


     

    Monday, February 25, 2008 9:57 PM

All replies

  • Something in your UControl class probably is not CLS Compliant.  You can add the [System.CLSCompliant(false)] attribute to the class or method to remove this error.  Or just remove the [assembly: System.CLSCompliant(true)] attribute from assembly.info. 

    If you actually want to fix this, in your code for UControl add [assembly: System.CLSCompliant(true)] to the assembly.info file and make sure you use all CLSCompliant types.
    Monday, February 25, 2008 12:29 PM
  • Hi Dan,
    I did what you said to me.

    If I add to the class the attribute
    <CLSCompliant(false)> to the class who defines the user control the CLS warning still remains.

    If I add to the method:

    <CLSCompliant(false)> _

    MyClass.Do(UserControl1)
    UserControl1 ends to be green underliyng for the warning.

     

    I checked my code in UserControl to find what goes wrong for the CLS compliant but I’m not able to find the reason.
    However warnings disappear only as I’ve written, when I add the attribute in the form.

    Thanks and regards,
    Mauro


     

    Monday, February 25, 2008 9:57 PM