How to prevent the error "Unable to read the project file ... The attribute "xmlns"?

How can I prevent the error “Unable to read the project file … The attribute “xmlns” in element is unrecognized” when my Unity project reloads in Visual Studio 2010? I know how to temporarily fix this issue by editing the project’s corresponding xml file and deleting out that offending attribute, but it’s really annoying to have to keep doing this every time my project reloads. Here’s a screenshot of the error:

Some details: I’m using Unity Pro 4.1.1f4 on a Windows 7 machine and Visual Studio 2010 Professional. I never had this problem until I switched my External Editor setting in Unity to MonoDevelop for debugging, and then switched back to Visual Studio. Here’s the node I have to remove/edit:

    <ProjectExtensions xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <MonoDevelop>
    <Properties>
    <Policies>
    <TextStylePolicy EolMarker="Windows" inheritsSet="Mono" inheritsScope="text/plain" scope="text/x-csharp" />
    <CSharpFormattingPolicy inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
    </Policies>
    </Properties>
    </MonoDevelop>
    </ProjectExtensions>

I’ve looked for posts about this error for a long time and I’m coming up empty. Thanks!

Unity 4.1.1 was retracted because of a different problem with external DLLs when building within Visual Studio and Mono Develop. It may or may not be related to the problem you’re experiencing.

Please upgrade to 4.1.2 and see if the problem still exists. If the problem haven’t been fixed by 4.1.2 please file a bug and list the bug number here and I’ll take a look.

I upgraded to 4.1.2 just now, per your suggestion, and I’m still getting the error. I reported a bug: #535618. Thanks!

Solution for those who googled this thread.

Problem was caused by read-only files, probably the visual studio solution, projects and user files. The only files that should be added to version control is those in the Assets and ProjectSettings folders. Under no circumstance should you add the solution files and Library folder to version control. As long as you use meta files and add those to version control along with your Assets and ProjectSettings everything else will be regenerated on demand.

4.2.0f4
same bug.
I use Mono for debugging and VS2012 for coding. They share csproj.
files neither on source control nor readonly
Sometimes (likely at unity start) ProjectExtensions is added to csproj preventing VS from load project.
look here:
http://bugtracker.sharpdevelop.net/issue/ViewIssue.aspx?ID=766&PROJID=4
same bug

I’m getting this error as well. Does anyone have a solution?

To fix this error open the project file in a text editor and remove the project extension nodes.

In my case i had to remove this:

<ProjectExtensions xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <MonoDevelop>
          <Properties>
            <Policies>
              <TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
              <CSharpFormattingPolicy IndentSwitchBody="True" AnonymousMethodBraceStyle="NextLine" PropertyBraceStyle="NextLine" PropertyGetBraceStyle="NextLine" PropertySetBraceStyle="NextLine" EventBraceStyle="NextLine" EventAddBraceStyle="NextLine" EventRemoveBraceStyle="NextLine" StatementBraceStyle="NextLine" ArrayInitializerBraceStyle="NextLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
            </Policies>
          </Properties>
        </MonoDevelop>
      </ProjectExtensions>

Kieran’s solution is technically correct but only works until you add a file or close/reopen Unity - then you’ll have to do it over again. Unity3D seems to be editing the csproj based upon whatever template it’s already using rather than recreating it for Visual Studio. Once it goes to Monodevelop it doesn’t want to go back.

Solution: Delete the sln and csproj files completely. Unity3D will completely regenerate them anyway and it will do it from scratch and correctly for Visual Studio but only if they are deleted completely. Once you do that and it does so correctly then they’ll stay correct and you won’t have to redo anything or delete them again.

5 Likes

McAden’s solution worked for me.

This worked for me too… thank you very very much :slight_smile:

I am using Unity 5.4.1f1 and MonoDevelop, but when I press the debug button I get a title error. No matter how many times csproj and sln erase, MonoDevelop will continue to display the title error.

Update:
I solved it myself. An error was displayed when setting Code Formatting on assembly. I fixed it when I set the Code Formatting in the project.