views:

267

answers:

2

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>
A: 

If you are targeting .NET 3.5 why are you doing a binding redirect to System.Xml v4.0.0.0? Make sure that your project references v2.0.0.0 of that assembly and that you have the following in your app.config:

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

Also make sure that you are targeting .NET Framework 3.5 and not .NET Framework 3.5 Client Profile. Finally make sure the client has .NET 3.5 installed.

Darin Dimitrov
I bound a redirect to the .NET 4.0 assembly because I assumed VS2010 had used that to compile the application in some way and expected the .NET 4.0 version. It makes sense really since that's all that changed - when compiled in VS2008 it worked fine. I'll give the `startup` element a go to see if it can successfully force the version.
Codesleuth
Yes but you are redirecting **to** v4.0.0.0 and not **from**. Also when you target .NET 3.5 VS2010 will automatically fix the references of the core assemblies.
Darin Dimitrov
I get the following error with the `startup` element in place: `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.`
Codesleuth
"Yes but you are redirect to v4.0.0.0 and not from." well as you can see from the `Loaded Assemblies` list in the first error I pasted in the question, it's loading v2.
Codesleuth
What happens if you create a new project from scratch in VS1010, target the .NET 3.5 framework and try to run it on the remote machine?
Darin Dimitrov
Yes it's loading v2. Isn't this that you want? I thought you want to target .NET 3.5.
Darin Dimitrov
I want it to use v2, yes. And it is, but this `MissingMethodException` is appearing, so I thought I would see if it's targetting a method from the .NET 4.0 version of the assembly. I'm unable to build a new visual studio application because I'm not at work right now, I'm RDPing in. I'll go install C# express at home and make it here, might take a while though :(
Codesleuth
Could you post your full app.config file please?
Darin Dimitrov
Posted, as requested.
Codesleuth
A: 

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.

Codesleuth

related questions