2

I have the following code:

using System.Xml;
namespace MyApp {
  public class Foo : IBar {
    public void SomeCallback(object sender, CallbackEventArgs e) {
      string s = e.Result;
      System.Xml.XmlDocument xml;  // <-- Error CS0234.
      ...

This results in error CS0234: The type or namespace name 'XmlDocument' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)

I have verified that System.Xml is included under "References" in Solution Explorer. It's listed as using 2.0.x.x, but that should be fine since the class allegedly existed then?

I'm not well versed in .net development, so I'm not sure how to troubleshoot this.

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
  • Yes. According to the Properties view the assembly's path is: `C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone\System.Xml.dll` – i_am_jorf Jan 07 '11 at 00:36

1 Answers1

4

Based on the comment you posted to your question it looks like you are building a Silverlight application. The type XmlDocument is not included in the Silverlight version of the framework. The recommended alternative is XDocument

Here is a tutorial page on using XML in a Silverlight application

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • Huh. Well, that does seem to be the case. Okay, well, it looks like `XDocument` has similar functionality... so, fine. But that was totally unexpected. It would be nice if that were actually in the documentation for the class. – i_am_jorf Jan 07 '11 at 00:42
  • @jeff: it kinda _is_ documented, in a way: http://msdn.microsoft.com/en-us/library/system.xml%28v=VS.95%29.aspx – John Saunders Jan 07 '11 at 01:29