- Home /
XmlException: a name did not start with a legal character 32 ( ) line 56 position 30
I am setting up Visual Studio for Unity but after installing the VS tools Unity i am getting a error when ever I create a script. Can anyone help me to solve this issue.
XmlException: a name did not start with a legal character 32 ( ) Line 56, position 30. Mono.Xml2.XmlTextReader.ReadName (System.String& prefix, System.String& localName) Mono.Xml2.XmlTextReader.ReadName () Mono.Xml2.XmlTextReader.ReadEntityReference (Boolean ignoreEntityReferences) Mono.Xml2.XmlTextReader.ReadReference (Boolean ignoreEntityReferences) Mono.Xml2.XmlTextReader.ReadText (Boolean notWhitespace) Mono.Xml2.XmlTextReader.ReadContent () Mono.Xml2.XmlTextReader.Read () System.Xml.XmlTextReader.Read () Mono.Xml.XmlFilterReader.Read () System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) System.Xml.Linq.XDocument.ReadContent (System.Xml.XmlReader reader, LoadOptions options) System.Xml.Linq.XDocument.LoadCore (System.Xml.XmlReader reader, LoadOptions options) System.Xml.Linq.XDocument.Load (System.IO.TextReader reader, LoadOptions options) System.Xml.Linq.XDocument.Parse (System.String s, LoadOptions options) System.Xml.Linq.XDocument.Parse (System.String s) SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnGeneratedCSProject (System.String path, System.String content) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.AssetPostprocessingInternal.CallOnGeneratedCSProject (System.String path, System.String content) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:75) UnityEditor.VisualStudioIntegration.SolutionSynchronizer.SyncProjectFileIfNotChanged (System.String path, System.String newContents) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:310) UnityEditor.VisualStudioIntegration.SolutionSynchronizer.SyncProject (MonoIsland island, System.Collections.Generic.Dictionary`2 allAssetsProjectParts, UnityEditor.Scripting.Compilers.ResponseFileData responseFileData, System.Collections.Generic.List`1 allProjectIslands) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:303) UnityEditor.VisualStudioIntegration.SolutionSynchronizer.GenerateAndWriteSolutionAndProjects (ScriptEditor scriptEditor) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:234) UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:206) UnityEditor.SyncVS.SyncIfFirstFileOpenSinceDomainLoad () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:199) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
hey did you work this out in the end, I am getting the same error?
I'm having the same problem. Everytime I create a new script it's giving this error. I'm using Visual Studio for $$anonymous$$ac and Unity 2018. Has anyone found a solution to this problem?
I'm having the same issue as well. And I get a missing .csproj message form Visual Studio. Driving me nuts.
Try this. Go into preferences in Unity under External tools and see if Editor Attaching is checked. If it is, uncheck it. Create a new script and then open that script and see if you still get those same errors.
Let me know if that helped.
Answer by Bunny83 · Jul 11, 2018 at 07:21 AM
Well, it's hard to tell anything specific from just getting thrown at a stacktrace. Though from the stacktrace we can see that the error comes from Unity's project file post processing when it tries to read back in a project file.
When inspecting the actual source code of the XmlTextReader it looks like you somehow have an ampersand (&) character somewhere (maybe in one of your filenames) that somehow did not get escaped properly. Ampersand characters denote an entity reference within an Xml document and they need to be escaped with &
. Make sure all your script, project and solution file names do not contain any ampersand characters.
Actually I even avoid having any space characters in file names as well and restrict myself to ascii characters. I follow this rule for at least the last 20 years as you can run into countless of issues otherwise.
This may be a bug in the software that created the solution file first. It might be Unity. If you can't resolve your issue you should file a bugreport and make sure you include your project with the .csproj ans .sln files. We can't reproduce the exact workflow how the project files are generated. That's something the Unity devs have to investigate. Make sure when you file a bugreport to include your project as well as the full stacktrace as shown in the question here. You may also add a link to this question.
@Bunny83 O$$anonymous$$, so it was in my na$$anonymous$$g. I did have a (&) in one of my folder names. Changing that folder name is what solved the problem. I tried a few different things to solve the problem and I wasn't sure exactly which one it was. Now I know. Thanks
Answer by sicklepickle · Jan 11, 2019 at 07:03 PM
You may have a malformed comment in one of your XMLs. ( same error during build process with an AndroidManifest.xml or partial AndroidManifest.xml btw )
e.g.
<-- this is a malformed comment -->
vs < !-- this is how it's meant to look with the exclamation mark -->
Your answer
Follow this Question
Related Questions
Visual Studio Code doesn't work for with unity 2 Answers
Legacy Animations and Unity 5 - What's The Deal? 1 Answer
Lightmapping Shadows Jagged 1 Answer
Unity 5 fatal error 3 Answers
Unity 5 crash on startup 1 Answer