BUG: The Microsoft.VisualBasic.dll assembly is not marked with the CLSCompliant(True) attribute (819352)



The information in this article applies to:

  • Microsoft .NET Framework 1.1
  • Microsoft .NET Framework 1.0
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

SYMPTOMS

The Microsoft.VisualBasic.dll assembly is not marked with the CLSCompliant(true) attribute. Therefore, you cannot use the Microsoft.VisualBasic.dll assembly in applications that do not permit assemblies to be referred or to be marked with the CLSCompliant(true) attribute.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

To determine if the Microsoft.VisualBasic.dll assembly is marked with the CLSCompliant(true) attribute, follow these steps:
  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. Under Project types, click to select Visual Basic Projects.
  4. Under Console Application, click to select Templates.

    By default, Module1.vb is created.
  5. Replace the code in the Module1.vb file with the following code:
    Option Explicit On 
    Option Strict On
    Imports System.Reflection
    
    Module Module1
    
        Sub Main()
            Dim oAssembly As [Assembly]
            Dim oAttributes() As Object
            Dim oCLSAttribute As CLSCompliantAttribute
    
            'Load the Microsoft.VisualBasic.dll Assembly.
            'Give the appropriate path on your computer to Microsoft.VisualBasic.dll.
            oAssembly = [Assembly].LoadFrom("C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Microsoft.VisualBasic.dll")
    
            'Get the CustomAttributes Array.
            oAttributes = oAssembly.GetCustomAttributes(GetType(CLSCompliantAttribute), True)
    
            If oAttributes.Length > 0 Then
                oCLSAttribute = CType(oAttributes(0), CLSCompliantAttribute)
    
                If oCLSAttribute.IsCompliant() Then
                    System.Console.WriteLine("The loaded Assembly is CLSCompliant.")
                    'Continue with the Application...
                    ' ....
                    ' .... 
                Else
                    System.Console.WriteLine("The loaded Assembly is not CLSCompliant.")
                    'Exit the Application.
                    Exit Sub
                End If
            Else
                System.Console.WriteLine("The loaded Assembly is not marked with CLSCompliant Attribute.")
                'Exit the Application.
                Exit Sub
            End If
    
        End Sub
    
    End Module
  6. On the Build menu, click Build Solution.
  7. On the Debug menu, click Start.

    You may receive the following message or a similar message in the Console window: The loaded Assembly is not marked with the CLSCompliant attribute.
  8. If you load an assembly that is marked with the CLSCompliant(true) attribute, such as System.dll, and you run the program again, you receive the following message on the Console window: The loaded assembly is CLSCompliant.

REFERENCES

For more information about the CLSCompliantAttribute class, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MinorLast Reviewed:2/3/2006
Keywords:kbvs2005doesnotapply kbvs2005swept kbvs2002sp1sweep kbDLL kbbug KB819352 kbAudDeveloper