Microsoft KB Archive/317578

= BUG: UML code generator places IMPORTS inside namespace declarations =

Article ID: 317578

Article Last Modified on 1/25/2006

-

APPLIES TO


 * Microsoft Visio for Enterprise Architects 2002
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



This article was previously published under Q317578



SYMPTOMS
When you use the Unified Modeling Language (UML) software diagram template that is included with Visio 2002 to generate Visual Basic .NET (VB.NET) code, you may receive the following compile error message when a class imports a class from another namespace:

&quot;Imports statement must precede any declaration&quot;



CAUSE
The code generator places the VB.NET IMPORTS statement inside the namespace declaration. The VB.NET language specification requires that you place the IMPORTS statement outside the namespace declaration.

NOTE: This behavior does not occur when you use C# to generate code. Although Microsoft Visio for Enterprise Architects (VEA) generates the C# USING command inside the namespace declaration, the C# language specification permits this construction.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Visual Studio .NET 2003.



Steps to Reproduce Behavior
To receive the error message, follow these steps:  Open Microsoft Visio. In Category, on the left, click Software. Follow these steps to create a package:  Select the UML Model Diagram template. In the Model Explorer on the left, right-click Top Package, point to New, and then click Package. Click OK to create a package named Package1.</li></ol> </li> Follow the previous steps to create another package named Package2.</li> Right-click Package1, point to New, and then click Class to create a class named Class1.</li> Right-click Package2, point to New, and then click Class to create a class named Class2.</li> Double-click Class1, click the Attributes category, create an attribute named Size, and then click Package2:Class2 on the Type drop-down list.</li> To generate the solution, follow these steps: <ol style="list-style-type: lower-alpha;"> On the main menu in the Visio environment, click UML, click Code, and then click Generate.</li> In the Generate dialog box, select Visual Basic as the target language, and then click to select all of the items on the right. The default location is C:\Documents and Settings\ \My Documents\.</li> Click Add classes to Visual Studio Project, and then click Class Library Template. Name the solution MySolution.sln. Click OK to close the dialog box.</li></ol> </li> In the UML Code Generation dialog box, click OK to create a directory.</li> Open MySolution.sln from the MyDocuments directory.</li> Build the solution.</li></ol>

Keywords: kberrmsg kbtshoot kbbug kbpending kbvs2002sp1sweep kbvs2005swept kbvs2005doesnotapply KB317578

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.