Question

I'm currently in the process of prototyping a few small apps, intended for release on Mac and Windows. Naturally this means Cocoa with Objective-C on the Mac and .NET with C# on Windows. Unfortunately, since these two languages are quite different, working on 4 apps is more like working on 8 since I have to do everything twice.

To some degree this is unavoidable, but I'm exploring ways to share some of the common code/functions that deal with platform independent stuff (calculations, formulas, etc.).

I considered C/C++, but since it needs to be compiled into a DLL for use in C# it doesn't seem worth it.

Now I'm looking at using a scripting language like Lua, which is showing some promise, but it's not without it's share of complications as well. Are there other ways that might be better?

Était-ce utile?

La solution

One way is to use Mono, a cross platform open-source development framework.

http://www.mono-project.com

Autres conseils

You can use C/C++ as a DLL, for C#. It's very easy to consume a C Dll from C# using .NET interoperability and marshaling. In fact, this was my preferred solution when developing for iPhone and WinPhone....

More about calling C Dll from C#, read MSDN, and this simple example: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx

Technically, you can write "managed C++ assemblies" for use in .NET applications, and you can mix C++ directly into Objective-C apps, but the syntax required to reference .NET Objects (myclass^) is different enough that you'd still end up not sharing very much.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top