Microsoft KB Archive/819352

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

Article ID: 819352

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft .NET Framework 1.0
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



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 &quot;Applies to&quot; section.



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

By default, Module1.vb is created.  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(&quot;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Microsoft.VisualBasic.dll&quot;)

'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(&quot;The loaded Assembly is CLSCompliant.&quot;) 'Continue with the Application...               ' ....                ' ....             Else System.Console.WriteLine(&quot;The loaded Assembly is not CLSCompliant.&quot;) 'Exit the Application. Exit Sub End If       Else System.Console.WriteLine(&quot;The loaded Assembly is not marked with CLSCompliant Attribute.&quot;) 'Exit the Application. Exit Sub End If

End Sub

End Module  On the Build menu, click Build Solution. 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.

</li> 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.

</li></ol>

<div class="references_section">