C# 程序在 Linux 的单声道下无法运行. [英] C# program doesn't work under mono in Linux.

查看:21
本文介绍了C# 程序在 Linux 的单声道下无法运行.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让我用 Visual C# 2010 编写的程序在 Linux 上运行.为此,我使用了 mkbundle 功能,因此潜在客户不必安装单声道.不幸的是,我对 Linux 或 Mono 不了解,所以我只是遵循了这个:c# cywgwin mono mkbundle windows 7 - 无法编译文件

I am trying to make my program written in Visual C# 2010 work on Linux. For that, I have used mkbundle feature, so that potential client doesn't have to install mono. Unfortunately I am not knowledgeable about Linux or Mono, so I have just followed this: c# cywgwin mono mkbundle windows 7 - cannot compile file

但由于某种原因,mkbundle 在最后写入 [FAIL],表示没有这样的文件或目录".我在下面粘贴了全文.有人知道怎么解决吗?

But for some reason mkbundle writes [FAIL] in the end, saying something about "No such file or directory". I have pasted the full text below. Does anybody know how to solve this?

$ mkbundle -o MyProgram MyProgram.exe --deps
OS is: Windows
Sources: 1 Auto-dependencies: True
   embedding: C:cygwinhomeSynapsMyProgram.exe
   embedding: C:Mono-2.10.8libmono4.0mscorlib.dll
   embedding: C:Mono-2.10.8libmono4.0System.Drawing.dll
   embedding: C:Mono-2.10.8libmono4.0System.dll
   embedding: C:Mono-2.10.8libmono4.0Mono.Security.dll
   embedding: C:Mono-2.10.8libmono4.0System.Configuration.dll
   embedding: C:Mono-2.10.8libmono4.0System.Xml.dll
   embedding: C:Mono-2.10.8libmono4.0System.Security.dll
   embedding: C:Mono-2.10.8libmono4.0System.Windows.Forms.dll
   embedding: C:Mono-2.10.8libmono4.0Accessibility.dll
   embedding: C:Mono-2.10.8libmono4.0Mono.WebBrowser.dll
   embedding: C:Mono-2.10.8libmono4.0Mono.Posix.dll
   embedding: C:Mono-2.10.8libmono4.0System.Data.dll
   embedding: C:Mono-2.10.8libmono4.0Mono.Data.Tds.dll
   embedding: C:Mono-2.10.8libmono4.0System.Transactions.dll
   embedding: C:Mono-2.10.8libmono4.0System.EnterpriseServices.dll
   embedding: C:Mono-2.10.8libmono4.0AForge.Imaging.dll
   embedding: C:Mono-2.10.8libmono4.0AForge.dll
   embedding: C:Mono-2.10.8libmono4.0AForge.Math.dll
Compiling:
as -o temp.o temp.s
gcc -mno-cygwin -g -o MyProgram -Wall temp.c `pkg-config --cflags --libs mono-2|d
os2unix`  temp.o
: No such file or directory
temp.c: In function `main':
temp.c:143: warning: implicit declaration of function `g_utf16_to_utf8'
temp.c:143: warning: assignment makes pointer from integer without a cast
temp.c:158: warning: assignment makes pointer from integer without a cast
[Fail]

当我尝试在 Linux 虚拟机上使用 mkbundle 时,我成功获得了 Linux 可执行文件,但每当我在 Ubuntu Linux VM(通过 Oracle VM Virtual Box)下运行该程序时都会出现以下错误:

When I tried to use mkbundle on Linux virtual machine, I successfully obtained Linux executable, but get the following error, whenever I run the program under Ubuntu Linux VM (by Oracle VM Virtual Box):

Unhandled Exception: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap.SetResolution (Single xDpi, Single yDpi) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:SetResolution (single,single)
  at AForge.Imaging.ColorReduction.ColorImageQuantizer.ReduceColors (System.Drawing.Bitmap image, Int32 paletteSize) [0x00000] in <filename unknown>:0 
  at FootMeasure.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap.SetResolution (Single xDpi, Single yDpi) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:SetResolution (single,single)
  at AForge.Imaging.ColorReduction.ColorImageQuantizer.ReduceColors (System.Drawing.Bitmap image, Int32 paletteSize) [0x00000] in <filename unknown>:0 
  at FootMeasure.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

推荐答案

正如我在评论中所说,如果你想生成一个自给自足的 Linux 可执行二进制文件,你不应该使用 mkbundle 在 Windows 上.您应该在 Linux 上运行 mkbundle 以获得 Linux 可执行文件(您可能应该关心 32 位的 Linux-X86 和 64 位的 Linux-x86-64,它们是不同).

As I said in a comment, if you want to produce a self-sufficient Linux executable binary, you should not use mkbundle on Windows. You should run mkbundle on Linux to get a Linux executable (and you probably should care about Linux-X86 in 32 bits and Linux-x86-64 in 64 bits, which are different).

我建议您在 Linux 机器中编译和运行您的应用程序(如果需要,您甚至可以在 VM 中安装 Linux 系统).因此,最简单的方法是在您的计算机上安装 Linux 发行版(例如 Debian).

I suggest you to compile and run your application in a Linux box (you could even install a Linux system inside a VM if you want). So the simplest way is to install a Linux distribution (e.g. Debian) on your machine.

我认为您不会轻易找到能够在 Windows 机器上编译针对 Linux 的 Mono 程序的交叉编译器.

I don't think you'll easily find a cross-compiler able to compile, on a Windows box, a Mono program targeted for Linux.

而您正在做的事情(在 Windows 上运行 mkbundle)正在生成一个 Windows 可执行文件(用于 Cygwin),它无法为您提供 Linux 二进制可执行文件,无论您尝试什么选项.

And what you are doing (running mkbundle on Windows) is producing a Windows executable (for Cygwin), it cannot give you a Linux binary executable, whatever option you try.

这篇关于C# 程序在 Linux 的单声道下无法运行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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