Data at the root level is invalid. Line 1, position 1

Last post 07-08-2008 6:38 AM by Sam.Dev. 21 replies.

Sort Posts:

  • Data at the root level is invalid. Line 1, position 1

    04-27-2006, 11:31 AM
    • Loading...
    • fsflier
    • Joined on 04-27-2006, 3:27 PM
    • Posts 6

    A C# ASP.NET program under development (VS 2005) works fine in the development box, using the virtual localhost server.
    Once I tried to "Publish" the site, pressing the [Build->Publish Web Site] menu option, it compiles and gives the following error:

    "Data at the root level is invalid. Line 1, position 1."

    The compilation fails at line 1, the line containing the [xml version="1.0" encoding="utf-8"] declaration.
    The simplied web.config file is shown below. As you can see it has nothing out of the ordinary.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <connectionStrings>
        blah blah...
      </connectionStrings>
      <appSettings>
        blah blah...
      </appSettings>
      blah blah...
      blah blah...
    </configuration>

    I have googled and found a few entries on this error, most of them talking about SOAP and web services (not what I'm doing here), and none of them have helped.

    I tried to recompile taking out the encoding=utf-8 section and also taking out the xmlns definition buit I still get the same error.

    Any ideas to try next?

    TIA

     

  • Re: Data at the root level is invalid. Line 1, position 1

    04-27-2006, 1:47 PM

    Hi fsflier,

    A few ideas:

    1. Can you confirm that the XML is well formed? Have you tried to open the XML file using IE and ensuring that there are no errors?
    2. Make sure there is no blank space before the root element.
    3. Maybe its a security problem? You could temporarily grant full access to that XML file and at least rule out the possibility.

    James Steele

  • Re: Data at the root level is invalid. Line 1, position 1

    04-27-2006, 2:26 PM
    • Loading...
    • fsflier
    • Joined on 04-27-2006, 3:27 PM
    • Posts 6

    Thanks James but that has been tested. It is well formed. It opens fine in IE and it works fine in VS2005 and when testing the app in localhost.

    There is no blank space before the first statement. One of the things I have tried is to see if there was anything starnge in Line 1, Position 1. When adding a top blank line the compiler complained that the XML line was not the first line. There is nothing wrong with the line per se.

    I did not suspect a security/access problem but it is something to try. Unfortunately that is not the case either.

    Thanks for the ideas. Still looking.

     

     

  • Re: Data at the root level is invalid. Line 1, position 1

    04-27-2006, 7:05 PM
    • Loading...
    • jbat1
    • Joined on 04-12-2006, 8:49 PM
    • Posts 14

    I've seen this error when there is no file where the object is trying to open it from.

    Make sure that the path you are specifiying is FOR sure where the file is.

  • Re: Data at the root level is invalid. Line 1, position 1

    04-28-2006, 9:29 AM
    • Loading...
    • fsflier
    • Joined on 04-27-2006, 3:27 PM
    • Posts 6

    jbat1:

    I don't understand your post. I'm not sure what path are we talking about as I'm not trying to run or open at this stage. All I'm doing is compiling/publishing to My Documents

    These are the exact steps:

    • I have an ASP.NET project inVS2005. It has a web.config
    • The source files reside in a different server (our development server)
    • I presss F5 to run locally (debugger) and it compiles ionm the fly and opens the default page in a temporary fake IIS in localhost (my workstaion does not have IIS). Everything works fine.
    • Project is finished. I want now to publish and start testing in QA/Staging server.
    • I open menu option: [Build->Publish Web Site]. A dialog appears pointing to my target location. This is in my local PC in MyDocuments\Visual Studio 2005\Projects\<my project>\Precompiled\<project name>. The only checkbox clicked (by default) is the first one: "Allow precompiled site to be updatable". Press OK
    • It compiles for a while and then comes up with this error: Data at root level is invalid...

    Thanks for the insight.

     

  • Re: Data at the root level is invalid. Line 1, position 1

    04-28-2006, 10:46 AM
    • Loading...
    • fsflier
    • Joined on 04-27-2006, 3:27 PM
    • Posts 6

    More info:

    When I double-click on the error it opens another file (tab) also called web.config with the following exact contents:

    vti_encoding:SR|utf8-nl
    vti_timelastmodified:TR|22 Mar 2006 13:48:12 -0000
    vti_extenderversion:SR|4.0.2.7802
    vti_cacheddtm:TX|22 Mar 2006 13:48:12 -0000
    vti_filesize:IR|6249

    I do not know what this info means or where it points to and why it mentions a 22 March date. I went to a co-developer and we created the project in his VS2005 (in his PC) and pointed to my existing app in the development server. He got the exact same error, thereby certifying that it is not my local PC and/or my copy of VS2005 but something wrong with the source.

    Still stuck. :(

  • Re: Data at the root level is invalid. Line 1, position 1

    04-28-2006, 11:32 AM
    • Loading...
    • jbat1
    • Joined on 04-12-2006, 8:49 PM
    • Posts 14

    Dangit! you caught me... sorry I just saw the error message, and honestly did not entirely read your post. I can see why you'd be confused.

    I don't have anything helpful for you on this one.

  • Re: Data at the root level is invalid. Line 1, position 1

    05-01-2006, 9:49 AM
    • Loading...
    • fsflier
    • Joined on 04-27-2006, 3:27 PM
    • Posts 6

    Found the problem!

    I checked the path to the file it was complaining about: [myProject]\_vti_cnf\web.config and saw that it was not a well-formed XML file. As it is called web.config it was confusing. I deleted the file and the problem was solved. Wonder why it was created to begin with. It shows I'm starting with ASP.NET, doesn't it. <bg>

  • Re: Data at the root level is invalid. Line 1, position 1

    05-01-2006, 11:37 AM
    Alright. Well I am not sure we helped much, but I'm glad you are back up and running. Good stuff.

    James Steele
  • Re: Data at the root level is invalid. Line 1, position 1

    09-01-2006, 12:44 PM
    • Loading...
    • jnc
    • Joined on 12-06-2002, 8:43 AM
    • Hamble - UK
    • Posts 333

    Good one

     

    thanks for the solution

    I suspect the rogue file was left over from an upgrade from 2003

     

     

    jnc
  • Re: Data at the root level is invalid. Line 1, position 1

    10-05-2006, 9:09 PM
    • Loading...
    • James_Hippolite
    • Joined on 06-01-2006, 1:47 AM
    • Wellington, New Zealand
    • Posts 2
    Exactly right.  I upgraded a project, had it working perfectly, but couldn't publish it.  That spurious _vti_cnf\web.config was there.  Getting rid of it fixed my problem straight away.  Thanks for the tip.
    Blessings,
    James Hippolite
    Senior Developer - Microsoft Technologies
    Workgroup Solutions Team - Shared Capability
    Telecom New Zealand Limited
    Wellington, New Zealand
  • Re: Data at the root level is invalid. Line 1, position 1

    03-29-2007, 4:48 PM
    • Loading...
    • Jbenisek
    • Joined on 03-29-2007, 8:11 PM
    • Posts 1

    I just started getting this. Didn't do anything I know of.  I have verified this file is there and works. Looked in side of it.


    Wss 3.0 has been running great until 11:00am today, didn't change anything.

     

     

    Line 1, position 1 looks like this in the document

    <browsers>
        <browser id="Safari2" parentID="Safari1Plus">
            <controlAdapters>
                <adapter controlType="System.Web.UI.WebControls.Menu"
                         adapterType="" />

    What am I missing here? Please Help

     

    Server Error in '/' Application.

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Data at the root level is invalid. Line 1, position 1.

    Source Error:

    Line 1:  <browsers>
    Line 2:      <browser id="Safari2" parentID="Safari1Plus">
    Line 3:          <controlAdapters>

    Source File: /App_Browsers/compat.browser    Line: 1


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

    [HttpParseException]: Data at the root level is invalid. Line 1, position 1.
       at System.Web.Configuration.BrowserCapabilitiesCodeGenerator.ProcessBrowserFiles(Boolean useVirtualPath, String virtualDir)
       at System.Web.Compilation.ApplicationBrowserCapabilitiesCodeGenerator.GenerateCode(AssemblyBuilder assemblyBuilder)
       at System.Web.Compilation.ApplicationBrowserCapabilitiesBuildProvider.GenerateCode(AssemblyBuilder assemblyBuilder)
       at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
    [HttpParseException]: Data at the root level is invalid. Line 1, position 1.
       at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
       at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
       at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
       at System.Web.Compilation.BrowserCapabilitiesCompiler.GetBrowserCapabilitiesType()
       at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
    [HttpException]: Data at the root level is invalid. Line 1, position 1.
       at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
       at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
       at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters)
    [HttpException]: Data at the root level is invalid. Line 1, position 1.
       at System.Web.HttpRuntime.FirstRequestInit(HttpContext context)
       at System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
       at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)

     

    Also getting this

     

    Event Type: Failure Audit
    Event Source: Security
    Event Category: Object Access
    Event ID: 560
    Date:  3/29/2007
    Time:  1:00:03 PM
    User:  *****\wss3pooldemo
    Computer: *****Description:
    Object Open:
      Object Server: SC Manager
      Object Type: SERVICE OBJECT
      Object Name: WinHttpAutoProxySvc
      Handle ID: -
      Operation ID: {0,19961704}
      Process ID: 840
      Image File Name: C:\WINDOWS\system32\services.exe
      Primary User Name: BLYSERVER$
      Primary Domain: *****
      Primary Logon ID: (0x0,0x3E7)
      Client User Name: wss3pooldemo
      Client Domain: *****
      Client Logon ID: (0x0,0x12E8C23)
      Accesses: Query status of service
       Start the service
       Query information from service
       
      Privileges: -
      Restricted Sid Count: 0
      Access Mask: 0x94


    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

     

    and this one

     

    Event Type: Warning
    Event Source: ASP.NET 2.0.50727.0
    Event Category: Web Event
    Event ID: 1310
    Date:  3/29/2007
    Time:  1:06:42 PM
    User:  N/A
    Computer: *****
    Description:
    Event code: 3006
    Event message: A parser error has occurred.
    Event time: 3/29/2007 1:06:42 PM
    Event time (UTC): 3/29/2007 7:06:42 PM
    Event ID: 45e791819dd04c249a7e269ddc530641
    Event sequence: 1
    Event occurrence: 1
    Event detail code: 0
     
    Application information:
        Application domain: /LM/W3SVC/1032202749/Root-7-128196688021727606
        Trust level: WSS_Minimal
        Application Virtual Path: /
        Application Path: C:\Inetpub\wwwroot\wss\VirtualDirectories\80\
        Machine name: ***** 
     
    Process information:
        Process ID: 3804
        Process name: w3wp.exe
        Account name: *****\dealer
     
    Exception information:
        Exception type: HttpException
        Exception message: Data at the root level is invalid. Line 1, position 1.
     
    Request information:
        Request URL: http://*****/it/_vti_bin/lists.asmx
        Request path: /it/_vti_bin/lists.asmx
        User host address: 172.16.1.98
        User: 
        Is authenticated: False
        Authentication Type: 
        Thread account name: *****\dealer
     
    Thread information:
        Thread ID: 1
        Thread account name: *****\dealer
        Is impersonating: False
        Stack trace:    at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
       at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
       at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters)
     
     
    Custom event details:

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    Event Type: Error
    Event Source: DCOM
    Event Category: None
    Event ID: 10016
    Date:  3/29/2007
    Time:  1:00:02 PM
    User:  *****\wss3pooldemo
    Computer: *****

    Description:
    The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
    {61738644-F196-11D0-9953-00C04FD919C1}
     to the user BLYTHEDESIGN\wss3pooldemo SID (S-1-5-21-4239727938-222710763-1804924817-1486).  This security permission can be modified using the Component Services administrative tool.

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

     

     

    Solution 

    I would like to meet the person that made this part of the system work as it does. I fixed this error I would think many people might have this over time.

     

    Idea of what could be the issues was only found here.

    http://forums.asp.net/thread/1270047.aspx

     

    In doing some editting on the intranet site which is WSS v3 I openned a file called web.config from the c:\inetpub\wwwroot\wss\virutaldirectories\80

    ok so no big deal didn't edit the file or change anything. I openned the file with SharePoint Designer after I did this I remembered I needed to work in these files in Virtual web designer and not sharepoint designer ok my bad didn't save anything seems stupid but I didn't give it a thought.

     

    Just openning the file seems to be enough to have the system create a sub folder called _vti_pvt or something like that. In trouble shoot this error I openned a few files and it created this folder and made a copy of each file I openned and put it in a sub folder with the same name I found 6 of these folders all new. I guess this file is not a true xml file and made the whole site crash for 2 hours.

     

    I deleted these directories and everything worked right away.

     

    The person that set this up should be shot.

  • Re: Data at the root level is invalid. Line 1, position 1

    05-23-2007, 3:02 AM
    • Loading...
    • epeji1101
    • Joined on 05-23-2007, 6:52 AM
    • Posts 1
    Thanks Jbenisek. My site is up and running again.Smile
  • Re: Data at the root level is invalid. Line 1, position 1

    07-12-2007, 12:08 AM
    • Loading...
    • iworm
    • Joined on 07-12-2007, 4:03 AM
    • Posts 1

    Just try Xml.Load() function instead of Xml.LoadXml(). 

  • Re: Data at the root level is invalid. Line 1, position 1

    07-25-2007, 4:43 PM
    • Loading...
    • pelegk2
    • Joined on 12-17-2004, 7:08 AM
    • Israel
    • Posts 51