I am stumped. I have a solution with a couple projects. Among them a little side project that doesn't do very much more than doing some XML reading / writing. It is a C# project and I am using XDocument / XElement from the System.Xml.Linq namespace. The project is targetting .NET 3.5 framework.
Now, when I try to run it, I get this strange exception:
"$exception {System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.IO.FileNotFoundException: Die Datei oder Assembly System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden."
I apologize that the message is in german; I'll give a translation of the core part: System.IO.FileNotFoundException: File or Assembly System.Xml.Linq, [...] not found. System cannot find the file.
The project references the System.Xml.Linq.dll residing in "%programfiles%\Reference Assemblies\Microsoft\Framework\v3.5". It exists and is registered in the GAC with corresponding version and public key token. When debugging, the exception occurs even before the tracer steps into the method in question, but after the code is compiled and I have run the project that calls the failing method.
The code is this:
public static SimpleTree<SankeyItem> XML2Tree(String xml)
{
XDocument document = XDocument.Load(xml);
SimpleTree<SankeyItem> tree = new SimpleTree<SankeyItem>();
XElement element = document.Root;
if (element.Name == "Node")
{
DoSomethingUseful(element)
}
else
{
throw new TreeParseException("Useful message here");
}
return tree;
}
If I comment out all the XSomething code, it works. Please, I have no idea what could cause this issue. :( For completeness sake: The string "xml" is neither null not empty (the "real" code checks that).
Thank you in advance!