Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: Error occurs when you access the Global.asax file for a Visual C# .NET Web Serviceproject in Visual Studio .NET


View products that this article applies to.

Symptoms

When you access the contents of the Global.asax file in Microsoft Visual Studio .NET for a Visual C# .NET Web Service project, you may receive the following error message:
This XML document is not well formed. It contains the following error: There is invalid data at the root level Line 1, position 1.

Additionally, the contents of the Web.config file may be overwritten.

↑ Back to the top


Cause

The problem occurs when a solution that contains a Visual C# .NET Web Service project has a Visual C++ .NET Web Service project added to the same solution. In Visual Studio .NET, the name of the solution is the name of the first project that was created in the solution. If a Visual C# .NET Web Service project is the first project that is created in the solution, the name of the solution is the same name as that Visual C# .NET Web Service project. When you add a Visual C++ .NET Web Service project to the solution, a directory is created in Internet Information Services (IIS) that has the same name as the name of the solution. Because the Visual C# .NET Web Service project has already created a directory in IIS with a project name that is the same as the solution name, both the Visual C# .NET Web Service project and the Visual C++ .NET Web Service project share this directory. When different Web Service projects share the same directory, this may cause the Web.config and the Global.asax files of one Web Service project to overwrite the Web.config and the Global.asax files of another Web Service project.

This problem only occurs when you add an additional Visual C++ .NET Web Service project. This does not occur with additional Visual C# .NET Web Service projects or with Microsoft Visual Basic .NET Web Service projects because they are created in separate directories that correspond to their project names. Projects are created in a directory that corresponds to the solution name instead of to the project name only when you add additional Visual C++ .NET Web Service projects.

↑ Back to the top


Workaround

To work around this problem, use one of the following methods:
  • If your solution has only one Visual C++ .NET Web Service project, create the Visual C++ .NET Web Service project as the first project in the solution.
  • If your multi-project solution has a project that is not Web Service-based, create that project first in the solution. When the Visual C++ .NET Web Service project is created, the directory that is created in IIS will not be an existing directory that was created for another Web Service project.

    Note Do not create more than one Visual C++ .NET Web Service project in a solution because the Web.config and Global.asax files of the previous Visual C++ .NET Web Service projects are overwritten by the later Visual C++ .NET Web Service projects.

↑ Back to the top


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 Microsoft Visual C# .NET (2003).

↑ Back to the top


More information

Steps to Reproduce the Behavior

  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. Click Visual C# Projects under Project Types, and then click ASP.NET Web Service under Templates.
  4. Add a Visual C++ Managed C++ Web Service project to the existing solution.
  5. Build the solution.
  6. In Solution Explorer, double-click Global.asax. You see the error that is mentioned in the "Symptoms" section.
  7. In Solution Explorer, double-click Web.config. You see that the contents are overwritten. For example, the defaultLanguage attribute of the compilation tag in the Web.Config file that was set to c# for the Visual C#-based Web Service is removed.

↑ Back to the top


Keywords: KB821317, kbweb, kbide, kbfix

↑ Back to the top

Article Info
Article ID : 821317
Revision : 5
Created on : 1/13/2006
Published on : 1/13/2006
Exists online : False
Views : 411