I’ve recently encountered the following exception on some machines.
Unhandled Exception: System.MissingMethodException: Method not found: ‘Void System.Xml.Xsl.XslCompiledTransform.Transform(System.Xml.XPath.IXPathNavigable, System.Xml.Xsl.XsltArgumentList, System.Xml.XmlWriter, System.Xml.XmlResolver)’.
It’s pretty clear from the this error that we’re trying to use a method on the System.Xml.Xsl.XslCompiledTransform class that does not exist.
The error seems to be isolated to Windows XP machines, either with or without .NET Framework 4.0 present, but works on the Windows 7 machines I’ve tried (all have both 3.5 and 4.0).
Reading the documentation, we can see that the signature used here is available in .NET 4.0, but not earlier.
Using the following code in a fresh .NET 3.5 console application, I’ve tried to compile the project with in a few different ways.
using System;
using System.Xml.XPath;
using System.Xml.Xsl;
namespace SystemXmlTestTool
{
class Program
{
static void Main(string[] args)
{
var transform = new XslCompiledTransform();
try
{
transform.Transform((IXPathNavigable)null, null, null, null);
}
catch (Exception e)
{
Console.WriteLine(e.GetType().Name);
Console.WriteLine(e.Message);
}
Console.ReadKey();
}
}
}
By running
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /target:clean
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /target:build
on the Windows 7 machine (as well as compiling it through Visual Studio 2010), the project will compile successfully.
If I do the same on the Windows XP machine (which also has .NET Framework 4.0 installed), I get a compiler warning telling me the obvious.
The question it all boils down to is; why does Visual Studio 2010/MSBuild on the Windows 7 machines (multiple) allow me to use this method in my code, when it’s not supposed to be present in .NET Framwork 3.5?
I’m suspecting that something is wrong with my environment, but I’m at a loss as to why.
Most likely, you only installed .NET Framework 3.5 Client Profile on the machines it failes and the full .NET Framework 3.5 on the machines it works.
I could compile the code on Windows 7 when targeting the full framework but not when targeting the Client Profile.
It looks like the documentation is not correct at this point.