System.MissingMethodException

编程入门 行业动态 更新时间:2024-10-10 03:29:22
本文介绍了System.MissingMethodException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在WinCE6上开发一个.NET CF 3.5应用程序,它将构建一个exe和一些dll.我在一个类库项目中定义了一个这样的示例类:

I'm developing a .NET CF 3.5 application on WinCE6 that will build an exe an some dlls. I have defined an example class like this in a class library project:

using System.ComponentModel; using System; namespace Utils { public static class Test { public static void runTest() { Exception e = new Win32Exception(0, "CreateToolhelp32Snapshot error."); } } }

在我的主要可执行项目中,我将调用 runTest()方法.编译时一切都很好.但是在运行时,尝试调用 runTest()时会引发以下异常:

From my main executable project I will call the runTest() method. Everything is well at compile time. But at run time the following exception is thrown when trying to call runTest():

System.MissingMethodException {"The version of the assembly System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089 cannot be loaded by this version of the Microsoft .NET Compact Framework."}

通过在调试中运行并将断点设置为 runTest(),我可以看到该方法均未输入...同样,如果在异常创建之前添加了一些普通代码,则该方法永远不会输入并引发异常.

By running in debug and setting a breakpoint into runTest() I can see that the method is neither entered... Also if I put some extra plain code before the exception creation the method is never entered and the exception is thrown.

但是,如果我接受Test类并将其直接放在主项目中(以便将其构建在exe中),一切正常...

However if I take the Test class and put it directly in the main project (so that it will be built inside the exe) everything works fine...

有人对发生的事情有任何了解吗?

Does anyone have any idea of what's going on?

推荐答案

当已安装的紧凑框架为3.5时,类库项目正在引用系统组件版本2.0.

The class library project is referencing the System component version 2.0 while the installed compact framework is 3.5.

在部署时,已部署了系统组件2.0,但CF 3.5无法加载它.修复了在库项目中对系统版本3.5的引用,一切正常.

At deploy time System component 2.0 was deployed but CF 3.5 was unable to load it. Fixed the reference to System version 3.5 in the library project everything worked fine.

更多推荐

System.MissingMethodException

本文发布于:2023-11-12 13:03:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581574.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:System   MissingMethodException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!