PRB: "Identifier Expected" Error Message When You Compile an Upgraded Visual C# .NET Project (821173)



The information in this article applies to:

  • Microsoft Visual J++ 6.0
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

SYMPTOMS

You can use Java Language Conversion Assistant (JLCA) to convert your Visual J++ projects and Java code to Visual C# .NET code. However, if you do the following, you receive an error message:
  1. Convert your Visual J++ project to Visual C# .NET by using JLCA.
  2. Add a new item (such as a Web Form or a Class) to the generated Visual C# .NET project.
  3. Try to build the project.

    You receive the following compiler error message:
    error BC30203: Identifier expected
Note You may also notice a red error indicator mark (or squiggly) after the namespace keyword in the code.

CAUSE

This behavior occurs because the wizard cannot assign a value to the RootNamespace namespace. When JLCA converts the Visual J++ project, JLCA generates a project file (for example, ProjectName.csproj) that contains project settings for the Visual C# .NET project. However, the JLCA tool does not assign a value for the RootNamespace namespace in the project file because the tool cannot identify the namespace value for the class that the wizard generates.

RESOLUTION

To resolve this problem, type the namespace in the project properties as follows:
  • Before you add a new item to the project, type the value for Default namespace in Properties for the project. To do this, follow these steps:
    1. In Solution Explorer of Visual Studio .NET, right-click the generated project name, and then click Properties.
    2. In the Default Namespace text box, type the value for namespace.
    3. Click OK.
    -or-
  • Before you add a new item to the project, type the value for RootNamespace in the project file. To do this, follow these steps:
    1. Start a text editor such as Notepad.
    2. In the text editor, open the project file of the generated Visual C# project.
    3. In the project file, type the value for RootNamespace.
    4. Save the project file.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual Studio .NET.
  2. On the File menu, point to Open, and then click Convert.
  3. Follow the onscreen instructions in the JLCA wizard to convert your Visual J++ project to a Visual C# .NET project.

    The wizard generates a Visual C# .NET project.
  4. In Solution Explorer of Visual Studio .NET, right-click the generated project name, point to Add, and then click Add New Item.
  5. In Templates, click Class, and then click Open.
  6. In the default code that the wizard generates for Class, you may notice a red error indicator mark after the namespace keyword. You notice the same behavior when you add a Windows Form, a Component Class, or a User Control class to the generated Visual C# .NET project.
  7. On the Build menu, click Build Solution.

REFERENCES

For more information about JLCA, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:5/28/2003
Keywords:kberrmsg kbUpgrade kbMiscTools kbCodeGen kbWndwClass kbWindowsForms kbprb KB821173 kbAudDeveloper