使现有的 C# Windows 应用程序在 linux 上运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/801047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Making existing C# Windows Application run on linux
提问by Josh
Duplicate: Run .NET exe in linux
Hello,
你好,
Is it possible to make my existing Windows Forms Application made using Visual Studio 2008 and .Net framework 2.0 run on Linux by recompiling in Linux with less/No code changes?
是否可以通过在 Linux 中以较少/无代码更改的方式重新编译,使我使用 Visual Studio 2008 和 .Net framework 2.0 制作的现有 Windows 窗体应用程序在 Linux 上运行?
Thanks
谢谢
回答by cruizer
very possible, however, depending on your application your mileage may vary. no-nos include third party libraries/DLLs that depend on COM and Win32 calls, and P/Invokes. you may also have to watch out for code that does file/directory concatenation, as unix uses "/" as directory separator while Windows uses "\".
很有可能,但是,根据您的应用程序,您的里程可能会有所不同。no-nos 包括依赖于 COM 和 Win32 调用以及 P/Invokes 的第三方库/DLL。您可能还需要注意执行文件/目录连接的代码,因为 unix 使用“/”作为目录分隔符,而 Windows 使用“\”。
回答by jay_t55
I suggest you recompile the same code in the Mono IDE, and by making any minor alterations that may be required. I've done this many times.
我建议您在 Mono IDE 中重新编译相同的代码,并进行任何可能需要的小改动。我已经做过很多次了。
回答by Michael Buen
yeah you can, last I checked, their DataGridView is improving, it can hide columns now, however their VirtualMode on dgv isn't working yet.
是的,你可以,上次我检查过,他们的 DataGridView 正在改进,它现在可以隐藏列,但是他们在 dgv 上的 VirtualMode 还没有工作。
I use Mono mostly for Remoting stuff, the DateTime type are now Remoting-compatible(yipee!) in Mono 2.4. before (in 1.9), I have to cast my datetime fields to string so it can be transported from and to Remoting middle-tier, this is not needed anymore in 2.4.
我主要使用 Mono 进行远程处理,DateTime 类型现在在 Mono 2.4 中与远程兼容(yipee!)。之前(在 1.9 中),我必须将日期时间字段转换为字符串,以便它可以在远程处理中间层之间传输,这在 2.4 中不再需要。
Use this guideline for writing portable software: http://mono-project.com/Guidelines:Application_Portability
使用本指南编写便携式软件:http: //mono-project.com/Guidelines: Application_Portability
an example:
一个例子:
To write portable software, you must make sure that you use the System.IO.Path.DirectorySeparatorChar (http:/monodoc/P:System.IO.Path.DirectorySeparatorChar) character when you must concatenate paths, or even better, use the System.IO.Path.Combine (http:/monodoc/M:System.IO.Path.Combine(string,string)) method to combine pathnames.
要编写可移植的软件,必须确保在必须连接路径时使用 System.IO.Path.DirectorySeparatorChar (http:/monodoc/P:System.IO.Path.DirectorySeparatorChar) 字符,或者更好的是使用 System .IO.Path.Combine (http:/monodoc/M:System.IO.Path.Combine(string,string)) 方法来组合路径名。
回答by Fredrik M?rk
You may pick up some info here: Run .NET exe in linux
你可以在这里获取一些信息:Run .NET exe in linux