Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System references not being recognized?

I am not entirely sure how to better word this question, as I am not entirely sure what the central cause is to these various reference problems, so I apologize in advance for the vague title.

I am writing apps in VS 2012 Express for Windows 8, targeting a winRT (ARM) surface tablet.

I am having multiple problems with references apparently being recognized in their entirety. For simplicity, let me illuminate with some examples.

I am writing some code involving SOAP xml.

First, if I reference "System.Xml" (as well as System.Xml.Linq) by explicitly including a "using.." line, it doesn't seem to actually do anything.

using System.Xml.Linq;
using System.Xml;
...
XmlDocument xmldoc = new XmlDocument();

throws "The type or namespace name 'XmlDocument' could not be found"

Likewise if I am more explicit:

using System.Xml.Linq;
using System.Xml;
....
System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();

throws "The type or namespace name 'XmlDocument' does not exist in the namespace 'System.Xml'" as well as the original error message.

Ok. I'm clearly missing something, but there's tons of google results for things like this.

I am running VS2012 on Windows 8 installed on VirtualBox, and thinking perhaps my installation was hosed, I first tried simply reinstalling VS2012, then repairing the installation when this did not seem to affect anything.

Next, I tried manually adding the reference to the .dll files in question. When I tried this, VS would not allow it, saying they are already included by default.

Next, I tried manually opening the .csproj file for my project, and adding Reference Include = "... lines for a few references which I seemed to be missing (like I said, I'm just using System.Xml as an example.) This didn't appear to change anything, as I was getting exactly the same errors.

Next, I went into "Add or Remove Programs" on a google-inspired hunch and, through Control Panel -> Add/Remove Programs, I turned on .Net Framework 4.5 Advanced Services. This unfortunately did not seem to have any effect.

Adding various .dll-containing paths to "Reference Paths" also did not seem to affect anything at all (that field was empty upon first installing VS.)

I am stumped. Am I missing .dlls or other files, even after repeated re-installation and repairs?

Note that I was able to at least create an XmlDocument by referencing Windows.Data.Xml, Windows.Data.Xml.Dom but that namespace seems to be lacking some methods I need.

like image 392
Danny Johnson Avatar asked Dec 05 '12 21:12

Danny Johnson


People also ask

How do I fix broken references in Visual Studio?

To fix a broken project reference by correcting the reference path. In Solution Explorer, right-click your project node, and then select Properties. The Project Designer appears. If you're using Visual Basic, select the References page, and then click the Reference Paths button.

How do I enable references in Visual Studio?

Restart Visual Studio, create a new C# UWP app project, and then right-click on the project and choose Add Reference.


2 Answers

System.Xml.XmlDocument is not available for Windows Store applications. Take a look at the MSDN page - classes, methods, and properties marked with the green shopping bag are the only ones you can use with Windows Store apps.

As for System and Windows namespace references, all of the ones you can use are already part of the .NET for Windows Store apps Reference in your project, so there's nothing that can be added.

enter image description here

like image 73
Jim O'Neil Avatar answered Sep 29 '22 08:09

Jim O'Neil


You probably need to actually add the reference to the dll in your project.

see the following link for details http://msdn.microsoft.com/en-us/library/wkze6zky.aspx

(The System.XML, and System.XML.Linq should be in the .Net tab)

like image 23
JFish Avatar answered Sep 29 '22 06:09

JFish