开发者

Mono Resources for Cross Platform Development

Is there a site or repository of information about Cross Platform development in mono? Obviously I know about Moma, and the Cross Platform Guidlines and I am using the Visual Studio Tools to run and debug applications in a Virtual Machine, however since I am migrating an old application I have dozens (if not hundreds) of PInvokes to migrate. Surely everyone who does this must have come across these problems before, and have solutions, or suggestions for solutions. Rather than post a hundred, "What is Mono equivalent of the user32.dll GetKeyState()" on stackoverflow (or maybe that is the solution), is there a repository (wiki like Pinvoke.net), or is it hidden in the mono forums from both their search and google search?

To answer the comment below, I am looking for Cross Platform ways of doing API calls. Obviously the best solution is to have a Managed way to do everything, but some kind of reference on how to do it on Windows, Linux and Mac would also be incredibly helpful. From the lack of response I am 开发者_运维知识库guessing that no such reference site exists, and perhaps it should be started. Even if the mono project started a wiki that started off with the Application Portability guidelines I am sure that it would grow over time and be of great use to the community.


I had about the same problem recently. I'm going to tell you my success story.

My application use some third party components. Some of them use PInvokes. On first MOMA run there was about 20 places. I replaced one component with similar crossplaform (without PInvokes) - 10 places left. About 5 places I had to code myself (found some workarounds easily) - 5 places left. These 5 places actually never called.

I assume many of our PInvokes are never called too.


Portability and use of APIs are mutually exclusive things. Using platform-specific APIs in the creation of some piece of software means that it won't work in any other platform, and there is no guarantee that there is even a similar API in the other systems. If you have code which makes heavy use of APIs you probably have no choice but to reimplement (parts of) the program if you wish to port it to another platform. This is NOT a something which could be solved by means of Find+Replace one API function with another (though this may be applicable in some cases), so the existence of a dictionary to translate between them is unlikely, and would be incomplete anyway. You have to rewrite the code! Read the manpages, google etc... and then if you have specific problems you can ask about them. Rather than spam this site with a question for every single thing...!

To avoid this whole APIs problem, rather than using the APIs directly when writing the code initially, you can use a portable library designed for the required functionality (Google should help you there), which will do the API calls for you as appropriate, and the maintainers of the library have to worry about all the platform-specific issues, so you don't have to! A good example of this (for C++) is SDL, which handles video, audio and controller devices. Note that it contains a portable version of GetKeyState! The .NET/Mono library itself hides a lot of API calls from you of course.

It is probably a good idea to use a library with a similar interface to the Windows API when porting your program (if one exists), rather than translate everything into Linux API (thus making the software portable), but I think the best plan is to see what the APIs used are for, then research how to do that in a portable way, rather than trying to translate each function individually. Keep in mind that the functions may be interdependent and can be grouped together around some set of tasks, when looking for solutions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜