Mar 4, 2011

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'

Mar 4, 2011

I have been getting this weird exception out of nowhere while compiling my solution. Turns out I had two projects in my solution using different System.Xml assembly. One using straight from .NET Framework 2.0 and other using assembly 2.0.5.0. ( from Silverlight runtime).

Referenced path were
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
&
C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Xml.dll respectively.

If a project file does not specify the exact reference assembly, compiler tries to use any matching assembly present in its cache. I could see the following reference in my csproj file.
<Reference Include="System.Xml"/>

I updated this reference with the correct version (along with the PublicKeyToken and Culture info) and made the SpecificVersion=True, enforcing compiler to use the specified assembly

<Reference Include="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<HintPath/>
</Reference>

This resolved my problem. Specifying strong references in project files will eliminate issues caused by same name assemblies.

1 comments:

Top Ad 728x90