简体   繁体   English

OpenNETCF 和 Windows 嵌入式标准操作系统

[英]OpenNETCF and Windows Embedded Standard O/S

If I have an application that is written in .net Compact Framework (and runs on Windows CE) and is theoretically compatible with Windows Embedded Standard O/S, would it still be compatible if it makes use of OpenNETCF functionality?如果我有一个用 .net Compact Framework 编写的应用程序(并在 Windows CE 上运行)并且理论上与 Windows 使用 OpenNETCF 的功能兼容,它是否仍然兼容?

Things like running.exe files with help of OpenNETCF for example.例如在 OpenNETCF 的帮助下运行.exe 文件之类的东西。 I am assuming that OpenNETCF uses P/Invoke under the hood, which might make the application incompatible with other OS than Windows CE.我假设 OpenNETCF 在后台使用 P/Invoke,这可能会使应用程序与 Windows CE 以外的其他操作系统不兼容。

I don't use P/Invoke in my code, but I can't asnwer for sure whether OpenNETCF does or does not.我没有在我的代码中使用 P/Invoke,但我无法确定 OpenNETCF 是否使用。

.net compact framework 2.0 and windows embedded standard .net 紧凑框架 2.0 和 windows 嵌入式标准

OpenNETCF does use P/Invoke extensively. OpenNETCF 确实广泛使用 P/Invoke。

It is effectively a wrapper for some core OS functionality in Windows CE and its derivatives, that is not otherwise implemented in the Compact Framework.它实际上是 Windows CE 及其衍生产品中某些核心操作系统功能的包装器,在 Compact Framework 中没有以其他方式实现。 In practice this means extensive P/Invoking of coredll.dll;在实践中,这意味着对 coredll.dll 的广泛 P/Invoking; the basic OS module for Windows CE. Windows CE 的基本操作系统模块。

Windows Embedded Standard is Windows XP. Windows 嵌入式标准是 Windows XP。 For this reason I would not expect you to be able to use OpenNETCF.因此,我不希望您能够使用 OpenNETCF。

Depending on the version you're using you may be able to get hold of the OpenNETCF code here (or buy the latest of course), and see what's going on under the hood.根据您使用的版本,您可能能够在此处获取 OpenNETCF 代码(当然也可以购买最新的),并查看引擎盖下发生了什么。 Also, what you may find is that the calls you are making to the OpenNETCF are actually implemented anyway when compiling for Windows Embedded Standard.此外,您可能会发现,在为 Windows 嵌入式标准编译时,您对 OpenNETCF 的调用实际上已经实现。

One way to approach this is to make another project to target this platform, containing exactly the same code files, but no reference to the OpenNETCF, then work through fixing the compile errors.解决此问题的一种方法是创建另一个以该平台为目标的项目,包含完全相同的代码文件,但不引用 OpenNETCF,然后修复编译错误。

You can add a Conditional compilation symbol to either the CE project or the Windows Embedded project then fix the errors like so (This example is not for OpenNETCF, but you get the idea):您可以向 CE 项目或 Windows 嵌入式项目添加条件编译符号,然后像这样修复错误(此示例不适用于 OpenNETCF,但您明白了):

    public static string ExecutingAssembly
    {
        get
        {
#if WindowsCE
            return Assembly.GetExecutingAssembly().GetName().CodeBase;
#else
            return Assembly.GetExecutingAssembly().Location;
#endif
        }
    }

Obviously you will then have to create a build for each platform as the outputted assemblies will now be different.显然,您必须为每个平台创建一个构建,因为输出的程序集现在会有所不同。

As Chris points out, the SDF makes heavy use of coredll P/Invokes.正如 Chris 所指出的,SDF大量使用 coredll P/Invokes。 That's not to say everything does, but it's certainly a minefield.这并不是说一切都可以,但这肯定是一个雷区。 I tend to have a CF project and a FFX project and places where I have overlap I use aliasing, like this:我倾向于有一个 CF 项目和一个 FFX 项目,并且我有重叠的地方我使用别名,如下所示:

#if WindowsCE
using Thread = OpenNETCF.Threading.Thread2;
#else
using Thread = System.Threading.Thread;
#endif

Then in the code you just do your normal然后在代码中你只是做你的正常

var thread = new Thread(...);

And things work out.事情就解决了。

Now ages ago we did start an interesting side project of creating a coredll "shim" for the desktop .很久以前,我们确实开始了一个有趣的副项目,即为桌面创建一个 coredll “shim” What that means is that ap/invoke to "coredll" on the desktop would actually call that DLL, which would in turn marshal the calls off to kernel32, user32 or whatever.这意味着桌面上对“coredll”的 ap/invoke 实际上会调用 DLL,这反过来会将调用编组到 kernel32、user32 或其他任何东西。 Our testing for what we implemented (and there's a fair bit there) showed that it worked just fine, so if you're using a limited subset of APIs, just dropping it on the PC might make the CF assembly "just work".我们对我们实现的东西的测试(并且那里有很多)表明它工作得很好,所以如果你使用有限的 API 子集,只需将它放到 PC 上可能会使 CF 程序集“正常工作”。

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

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