System.MissingMethodException [英] System.MissingMethodException

查看:73
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆