在不同计算机上运行应用程序时出现 MissingMethodException

发布于 2024-09-02 17:12:38 字数 4156 浏览 10 评论 0原文

我遇到一个问题,我在 Visual Studio 2010 上编译我的应用程序,同时以 .NET Framework 3.5 为目标,将其部署到客户端服务器,却发现它给出了以下错误:

************** 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

它说它正在寻找的方法是这样的: XslTransform.Transform 方法(IXPathNavigable、XsltArgumentList、XmlWriter、XmlResolver) (支持:4、3.5、3.0、2.0、1.1)

我尝试使用 assemblyBinding 元素如下:

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

但现在应用程序不会' t 运行,并将其放入事件日志中:

事件类型 clr20r3,P1 myapplication.exe,P2 3.85.12.27583, P3 4be9757f、P4 系统配置、 P5 2.0.0.0、P6 4889de74、P7 1a6、P8 136、P9 ioibmurhynrxkw0zxkyrvfn0boyyufow,P10 无。

因此,总而言之,(1) 有谁知道为什么应用程序找不到列出的方法,以及 (2) 为什么它不允许我重定向到 System.Xml 的 .NET 4.0 版本?

感谢任何帮助,我完全陷入困境!

按照要求的app.config:

<?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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薄荷港 2024-09-09 17:12:38

如果您的目标是 .NET 3.5,为什么要绑定重定向到 System.Xml v4.0.0.0?确保您的项目引用该程序集的 v2.0.0.0,并且您的 app.config 中包含以下内容:

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

还要确保您的目标是 .NET Framework 3.5 而不是 。 NET Framework 3.5 客户端配置文件。最后确保客户端已安装.NET 3.5。

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.

北渚 2024-09-09 17:12:38

我已经使用此 < 解决了该问题code>Transform 方法而不是前一个方法(我之前将 null 传递到最后的 XmlResolver 参数中)。

奇怪的是,这在我的开发和测试机器上起作用,而不是在服务器上起作用。

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.

硪扪都還晓 2024-09-09 17:12:38

尝试查看程序集文件夹中 System.XML.dll 的文件版本。您系统上的文件的最后一位很可能与服务器上的不同。在您的情况下“2.0.50727.3082”似乎没有指定的方法签名。开发计算机上的版本是“2.0.50727.8009”,它确实具有所需的方法签名。

编辑:决定使用该方法的 XMLReader 版本。即使我们可以从本地计算机在 GAC 中注册较新的版本(不会给出运行时错误),并且消除了错误。但由于 .NET 可以升级到新版本并覆盖 GAC,我们需要小心新版本不会出现同样的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文