未处理的异常:在Mono上运行时,在.NET 4上编译时出现System.TypeLoadException [英] Unhandled Exception: System.TypeLoadException when running on mono, compiled on .NET 4

查看:296
本文介绍了未处理的异常:在Mono上运行时,在.NET 4上编译时出现System.TypeLoadException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C#编写了一个小应用程序,但没有问题.目标框架是.NET 4.

I have written a small app in C# which works no problem. Target Framework is .NET 4.

当我在linux-mono下运行该应用程序时,该应用程序启动没有问题.

When I run the app under linux - mono , the app starts no problem.

但是我似乎在单声道下的线程问题.

However I seem to be having a problem with Threading under mono.

以下代码:

 try
                {
                    Thread oThread = new Thread(new ParameterizedThreadStart(this.SendSms));
                    oThread.IsBackground = true;
                    oThread.Start(_data);

                    while (!oThread.IsAlive)
                    {
                        Console.WriteLine("Sleeping...");
                        Thread.Sleep(1);
                    }

                }
                catch (TypeLoadException tlex)
                {
                    Console.WriteLine("TypeLoadException: " + tlex.Message);

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

它似乎没有到达SendSms方法,而是引发了以下错误:

It doesn't seem to get to the SendSms method, but instead throws the following error:

Unhandled Exception: system.TypeLoadException: A type load exception has occurred. at System.Threading.Thread.StartUnsafe () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred. at System.Threading.Thread.StartUnsafe () [0x00000] in <filename unknown>:0

现在我是Mono的新手,所以首先不知道为什么会发生这种未处理的异常,因为参数化线程的代码来自"http://www.mono-project.com/ThreadsBeginnersGuide".其次,为什么当我放入 捕获(TypeLoadException tlex)

Now I am new to Mono so don't know firstly why this unhandled exception is occuring as the code for the parameterized thread comes from 'http://www.mono-project.com/ThreadsBeginnersGuide'. And secondly, why is it unhandled when i put in the catch (TypeLoadException tlex)

请协助.

谢谢

尼尔

推荐答案

也许这个答案可以帮助您..

may be this answer can help you ..

Mono-LibreOffice System.TypeLoadException

您是否尝试过在mono下编译相同的程序并尝试运行它?

have you tried to compile the same program under mono and tried running it ??

您还使用哪个版本的Mono?可能需要将其更新为最新版本.

Also which version of mono are you using?? may need to update it to the latest.

mono --version

mono --version

v 2.10似乎是最新的稳定版本.
http://www.go-mono.com/mono-downloads/download. html

v 2.10 looks to be the latest stable release.
http://www.go-mono.com/mono-downloads/download.html

这篇关于未处理的异常:在Mono上运行时,在.NET 4上编译时出现System.TypeLoadException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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