System.MissingMethodException

我只是一个虾纸丫 提交于 2019-12-13 07:28:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/41592782/system-missingmethodexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!