【问题标题】:Using Mono packages from badgerports, getting an exception on runtime使用来自 badgerports 的 Mono 包,在运行时出现异常
【发布时间】:2012-08-28 17:44:25
【问题描述】:

我正在尝试将一个用 C# 编写的 .NET 应用程序移植到 linux 中。
使用 MoMa 工具进行的兼容性测试表明该应用程序是兼容的。 我使用 Visual Studio 2010 编译了代码,并将生成的 .exe 文件复制到我的 Ubuntu VM(运行 10.04 LTS)。

我已经安装了带有 badgerport 源的单声道(来自 http://badgerports.org/lucid.html)。我看到我在 /usr/lib/mono 目录中有 4.0 的库:

user@ubuntu:~$ ls -l /usr/lib/mono
total 52
drwxr-xr-x   3 root root  4096 2012-08-27 07:15 2.0
drwxr-xr-x   3 root root  4096 2012-08-27 07:15 3.5
drwxr-xr-x   3 root root 12288 2012-08-27 07:15 4.0
drwxr-xr-x   2 root root  4096 2012-08-27 07:14 compat-2.0
drwxr-xr-x 145 root root 12288 2012-08-27 07:15 gac
drwxr-xr-x   3 root root  4096 2012-08-27 07:15 mono-configuration-crypto
drwxr-xr-x   2 root root  4096 2012-08-27 07:15 monodoc
drwxr-xr-x   3 root root  4096 2012-08-27 07:15 xbuild
drwxr-xr-x   3 root root  4096 2012-08-27 07:15 xbuild-frameworks

当我查看 mono 的手册页时,我在顶部看到 Mono 2.5。
mono -V 返回以下内容。

user@ubuntu:~$ mono -V
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-1~dhx1~lucid1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS:           __thread
SIGSEGV:       altstack
Notifications: epoll
Architecture:  x86
Disabled:      none
Misc:          softdebug 
LLVM:          supported, not enabled.
GC:            Included Boehm (with typed GC and Parallel Mark)

这是我尝试运行应用程序时的输出。

user@ubuntu:~$ mono MyApplication.exe 

Unhandled Exception: System.TypeLoadException: A type load exception has occurred.
at MyApplication.ConsoleRunner..ctor () [0x00000] in <filename unknown>:0 
at MyApplication.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.
at MyApplication.ConsoleRunner..ctor () [0x00000] in <filename unknown>:0 
at MyApplication.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

对正在发生的事情有什么见解,我可以做些什么来解决它?不幸的是,由于其他开发限制,我仅限于使用 Ubuntu 10.04。

【问题讨论】:

  • 如果我是你,我会尝试在 Ubuntu 上构建单声道开发项目,并检查调试器出了什么问题..
  • 您至少需要使用 Windows Mono 编译器来编译程序。至于否决票的原因,这表明您缺乏研究。
  • @IDontKnowPopePersonally - 谢谢,我认为这最初是一个单声道设置或配置问题,所以我没想到要调试它。我会试一试看看发生了什么。
  • @Ramhound - 不,我从来没有使用过单声道,所以我什至不知道从哪里开始。我正在尝试学习。你缺乏帮助。

标签: c# ubuntu mono


【解决方案1】:

您绝对必须使用 Mono 编译器进行编译,至少不是设计使然。尝试使用MONO_LOG_LEVEL="debug" mono your_software.exe 运行,您将看到尝试查找程序集和其他可能有用的信息。并把它放在这里;)

【讨论】:

  • 感谢提示,不知道有日志级别。我解决了之前遇到的问题,该应用程序现在正在运行。问题是我没有正确引用一些 dll。另一方面,Mono 不支持 SerialPort.ReceivedBytesThreshold,所以我必须稍微不同地处理串行输入。输出效果很好。不过感谢您的帮助,如果我有声誉,我会投票赞成。
猜你喜欢
  • 1970-01-01
  • 2013-03-03
  • 1970-01-01
  • 2018-06-23
  • 1970-01-01
  • 2023-03-06
  • 2019-09-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多