开发者

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="e-monitoring@myapplication.co.uk">
        <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>


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.


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.


Try looking into the file version for System.XML.dll in the assembly folder. chances are that the last bit of the file on your system are different then the ones on server. in your case "2.0.50727.3082" does not seem to have the specified method signature. The version on the development machine was "2.0.50727.8009" which did have the required method signature.

EDIT: Decided to use the XMLReader version of the method. Even though we could register the newer version in the GAC(which did'nt give runtime error) from our local machine and that removed the error. but since the .NET could upgrade to a newer version and overwrite GAC we would need to be careful that the newer version would not have same problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜