Asp.net vnext and XDocument

I am having a problem with the latest beta version of .net and the Xdocument library.

My project.json looks like this:

"dependencies": { "Microsoft.AspNet.Mvc": "6.0.0-beta4", "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", "Microsoft.AspNet.StaticFiles": "1.0.0-beta4", "System.Xml.XDocument": "4.0.10-beta-23109" }, "commands": { "web": "Microsoft.AspNet.Hosting --config hosting.ini" }, "frameworks": { "dnx451": { } }, 

And my code is as follows:

 var xd = XDocument.Parse(str); 

But I get an error message:

 Severity Code Description Project File Line Error CS0433 The type 'XDocument' exists in both 'System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Xml.XDocument, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' WebApplication2.DNX 4.5.1 ValuesController.cs 23 

Just trying to solve it using System.Xml.Linq.XDocument xd = or System.Xml.XDocument xd = does not work, what else can I try?

+6
source share
1 answer

I solved this by adding the System.Xml.XDocument dependency as a framework assembly (this means that one of the GAC installed with the full version of .Net will be used) for the dnx451 structure and only as a nuget package for the dnxcore structure:

 "frameworks": { "dnx451": { "frameworkAssemblies": { "System.Xml.Linq": "4.0.0.0" } }, "dnxcore50": { "dependencies": { "System.Xml.XDocument": "4.0.10" } } } 

I think that when compiling the dnx451 version, it gets confused between the nuget package and the DLL installed with the full .Net framework

+7
source

All Articles