简体   繁体   中英

System.MissingMethodException

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.");
        }
    }

}

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."}

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.

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?

The class library project is referencing the System component version 2.0 while the installed compact framework is 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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