0

The whole internet is full of such problem:

due to some reason web site become uncompilable with the following error:

The type 'System.Xml.IXmlLineInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

It often appear in places that don't have any relationship to xml... In my case it is in the following line of the ascx file:

        <br /><%#((Team)Container.DataItem).Href()%>

Or another one:

 Hello, <%=_clu.User.Href(true)%>! ( <a href="/login/UsE_1.aspx">Exit</a> )

I saw I recommendation to remove all references to library, stop IIS, delete all temp files (I deleted usual temp files from user folder, from window folder, deleted everything from "Temporary ASP.NET Files" folder of all .NET folders...

Nothing helped...

Don't know, how to continue work at all... Reinstall Windows? :(

P.S. I have ASP.NET 4.0 web site

P.P.S. When I try to add reference VS tolds me:

The Web site is already referencing the assembly 'System.XML'.

What is additionaly confuses me is that "XML" is written in upper case. But the 'standard' .NET assembly has "System.Xml"...

Budda
  • 18,015
  • 33
  • 124
  • 206
  • Why don't you just include the reference? – Earlz Jan 12 '11 at 04:58
  • I've tried, see "P.P.S" section just added into original question – Budda Jan 12 '11 at 05:07
  • Probably currently '4.0' version is used while application wants 2.0.5.0 version? How can I get it? – Budda Jan 12 '11 at 05:08
  • No, I've added System.xml.dll from "C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\" into 'bin' web site folder - didn't help... :( – Budda Jan 12 '11 at 05:12

2 Answers2

1

I've got that problem appeared after including 3rd part library. I had the previous version of library and the new one. I've resolved problem by the following:

  1. rolling back my source code to previous version;
  2. removed all instances and source code of those 3rd party library (temporary files, etc);
  3. get the ONLY 1 copy of dll of required library;
  4. removed references to OLD lib;
  5. added references to the new one.
Budda
  • 18,015
  • 33
  • 124
  • 206
0

I has a similar error to this. The resolution was actually stupidly simple.

The problem arrises in that your project has a reference to an assembly running on a different version of the .Net framework. Though fixing this would most probably fix it, it could take a long while to track down (depending on the size of the project).

My solution was to go through the Using clause at the top of the code page and remove any uneeded. Using clause's found within the code declarations.

Error Using clause

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

The Invalid Using clause

using System.Xml.Linq;

This namespace is a .Net 4 namespance and because of the way .Net works it was trying to load the System.Xml.Linq.dll file, which it did successfully, but then it would throw the error that you've received.

Priest of Psi
  • 851
  • 1
  • 7
  • 12