You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Xml.ReaderWriter, Version = 4.1.0.0, ... The system cannot find the file specified
#429
Closed
mauricio-bv opened this issue
Jul 20, 2017
· 6 comments
When trying to use the 'XmlNodeType" enumeration the program crashes with the error below:
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Xml.ReaderWriter, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
using System;
using System.Diagnostics;
using System.Xml;
using System.Xml.Linq;
namespace XmlDotNetSandardClass
{
public class DotNetStandardClass
{
XDocument doc = new XDocument(
new XComment("This is a comment"),
new XElement("Root",
new XElement("Child1", "data1"),
new XElement("Child2", "data2"),
new XElement("Child3", "data3")
)
);
public void MethodThatFails()
{
foreach (XNode n in doc.Nodes())
{
if (n.NodeType == XmlNodeType.Element)
{
Debug.WriteLine(n.ToString());
break;
}
}
}
public void MethodDoesNotFail()
{
XDocument doc = new XDocument(
new XComment("This is a comment"),
new XElement("Root",
new XElement("Child1", "data1"),
new XElement("Child2", "data2"),
new XElement("Child3", "data3")
)
);
foreach (XNode n in doc.Nodes())
{
// This method does not fail
//if (n.NodeType == XmlNodeType.Element)
//{
Debug.WriteLine(n.ToString());
break;
//}
}
}
}
}
The text was updated successfully, but these errors were encountered:
Which platform are you trying to run this on? .NET Core? Desktop?
.NET Standard is just a reference assembly with no implementation that will serve only for compile time, but depending on where do you want to run it you might be missing a package.
Adding the NetStandard.Library NuGet package works. Also, instead of adding the NuGet package, I added a reference to the \packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll file and it also worked.
Why do I need to ad a .Net Standard reference to my .NET Desktop application? Doesn't the .Net Desktop Framework implement everything that is in the .Net Standard? It doesn't make sense to me that the consumer of a .NetStandard targeted assembly has to reference .NetStandard dlls.
I created a .Net Standard Project.
When trying to use the 'XmlNodeType" enumeration the program crashes with the error below:
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Xml.ReaderWriter, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
A simple application that reproduces the issue can be find in the following GitHub repository:
(https://github.com/mauricio-bv/Public.git)
The application is: "XmlReadWriterError"
Link to the github code:
(https://github.com/mauricio-bv/Public/tree/master/XmlReadWriterError)
Below the code of the failing class:
The text was updated successfully, but these errors were encountered: