我正在WinCE6上开发一个.NET CF3.5应用程序,它将构建一个可执行文件和一些dlls。我在一个类库项目中定义了一个这样的示例类:
using System.ComponentModel;
using System;
namespace Utils
{
public static class Test
{
public static void runTest()
{
Exception e = new Win32Exception(0, "CreateToolhelp32Snapshot error.");
}
}
}从我的主可执行项目中,我将调用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."}通过在debug中运行并在runTest()中设置断点,我可以看到该方法既没有输入...此外,如果我在创建异常之前添加了一些额外的普通代码,则永远不会进入该方法,并且会抛出异常。
但是,如果我将Test类直接放在主项目中(这样它就会构建在exe中),一切都会正常工作……
有人知道这是怎么回事吗?
https://stackoverflow.com/questions/41592782
复制相似问题