Search code examples
app-configgacmissingmethodexceptionassemblybindingsystem.xml

MissingMethodException when running application on different computer


I have a problem where I compiled my application on Visual Studio 2010 while targetting the .NET Framework 3.5, deployed it to a client server, only to find it gives me the following error:

************** Exception Text **************
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)'.
************** Loaded Assemblies **************
[...]
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

The method it says it's looking for is this: XslTransform.Transform Method (IXPathNavigable, XsltArgumentList, XmlWriter, XmlResolver) (Supported in: 4, 3.5, 3.0, 2.0, 1.1)

I've tried setting up a redirect to the .NET Framework 4.0 version of the same DLL using the assemblyBinding element like so:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
          <assemblyIdentity name="System.Xml"
                            publicKeyToken="b77a5c561934e089"
                            culture="neutral" />
          <bindingRedirect oldVersion="2.0.0.0"
                           newVersion="4.0.0.0"/>
          <codeBase version="4.0.0.0"
                    href="file:///C:/WINDOWS/Microsoft.NET/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll" />
       </dependentAssembly>
    </assemblyBinding>
</runtime>

But now the application won't run, and puts this in the event log:

EventType clr20r3, P1 myapplication.exe, P2 3.85.12.27583, P3 4be9757f, P4 system.configuration, P5 2.0.0.0, P6 4889de74, P7 1a6, P8 136, P9 ioibmurhynrxkw0zxkyrvfn0boyyufow, P10 NIL.

So, in summary, (1) does anyone know why the application can't find the method listed, and (2) why doesn't it let me redirect to the .NET 4.0 version of System.Xml?

Any help is appreciated, I'm totally stuck!

app.config as requested:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>

  <configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="myapplication.Properties.UserSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.net>
    <mailSettings>
      <smtp from="[email protected]">
        <network defaultCredentials="true" host="192.168.0.132" port="25" password="" userName="" />
      </smtp>
    </mailSettings>
  </system.net>

  <appSettings file="">
    <add key="ReportDataCollectionTimeout" value="360" />
    <add key="AllowedDatabaseBuild" value="3" />
    <add key="AllowedDatabaseRevision" value="085" />
    <add key="HelpNamespace" value="myapplicationHelpfile.chm" />
    <add key="ProFormaHomePageUri" value="https://myapplication.co.uk/" />
    <add key="ProFormaLoginPageUri" value="https://myapplication.co.uk/login.aspx" />
  </appSettings>
    <connectionStrings configSource="connectionStrings.config" />
  <userSettings>
    <myapplication.Properties.UserSettings>
      <setting name="RequiresUpgrade" serializeAs="String">
        <value>True</value>
      </setting>
    </myapplication.Properties.UserSettings>
  </userSettings>
</configuration>

Solution

  • I've solved the problem by using this Transform method instead of the previous one (where I was previously passing null into the XmlResolver argument at the end).

    Strange how this worked on my development and test machine, and not the server.