简体   繁体   English

System.MissingMethodException

[英]System.MissingMethodException

I'm developing a .NET CF 3.5 application on WinCE6 that will build an exe an some dlls. 我正在WinCE6上开发一个.NET CF 3.5应用程序,它将构建一个exe和一些dll。 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.");
        }
    }

}

From my main executable project I will call the runTest() method. 在我的主要可执行项目中,我将调用runTest()方法。 Everything is well at compile time. 编译时一切都很好。 But at run time the following exception is thrown when trying to call runTest() : 但是在运行时,尝试调用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."}

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. 通过在debug中运行并在runTest()设置断点,我可以看到该方法都没有输入...同样,如果在异常创建之前添加了一些普通的代码,则永远不会输入该方法,并且会引发异常。

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... 但是,如果我接受Test类并将其直接放在主项目中(以便将其构建在exe中),则一切正常。

Does anyone have any idea of what's going on? 有谁知道发生了什么吗?

The class library project is referencing the System component version 2.0 while the installed compact framework is 3.5. 当安装的紧凑框架为3.5时,类库项目将引用系统组件版本2.0。

At deploy time System component 2.0 was deployed but CF 3.5 was unable to load it. 在部署时,已部署了系统组件2.0,但CF 3.5无法加载它。 Fixed the reference to System version 3.5 in the library project everything worked fine. 修复了在库项目中对系统版本3.5的引用,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM