Windows kernel32 在 Linux 上的 Mono 中运行 [英] Windows kernel32 functions in Mono on Linux

查看:61
本文介绍了Windows kernel32 在 Linux 上的 Mono 中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前从某个地方下载了这个非常简单的 ini 类,但是现在我使用的是单声道,我遇到了它从 kernel32 导入东西的问题

I got this awesomely simple ini class that I downloaded from somewhere a while ago, but now that I'm using mono I'm running into the issue that it's importing stuff from kernel32

[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
    string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,
            string key, string def, StringBuilder retVal,
    int size, string filePath);

在单声道上(在 linux 中)给出错误 DLLNotFoundException: kernel32

Which on mono (in linux) gives the error DLLNotFoundException: kernel32

有没有办法让它与单声道一起工作?也许在编译时将整个内容嵌入到程序集中(如果这甚至有意义,我不知道).还是我必须创建/找到一个不使用 WinAPI 的 ini 类?(妮妮突然想起).

Is there any way to get this to work with mono? Maybe embed the whole thing into the assembly at compile time (if that even makes sense at all, I wouldn't know). Or will I have to create/find an ini class that doesn't use WinAPI? (Nini springs to mind).

如果 WinAPI 的东西可以与 Mono 一起工作,我真的很喜欢它,有什么想法吗?

I'd really like it if WinAPI stuff could work with Mono, any thoughts?

推荐答案

你需要在原生 .NET 中重写这些函数的功能,才能在 Mono/Linux 上使用它们(除非你能说服 Mono 和 Wine 很好地运行).

You'll need to rewrite the functionality of those functions in native .NET to use them on Mono/Linux (unless you can convince Mono and Wine to play nicely).

如果 INI 文件受到控制,那么您可以通过简单的文件/字符串操作逃脱,但无论如何您最好还是转向更跨平台的东西.

If the INI files are controlled, then you may get away with simple file/string manipulation, but then you may be better off moving to something a bit more cross platform anyway.

这篇关于Windows kernel32 在 Linux 上的 Mono 中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆