c# - 单测试安装失败并出现 System.NullReferenceException
问题描述
我在 debian(Linux 5.7.0-1-amd64 #1 SMP Debian 5.7.6-1 (2020-06-24) x86_64 GNU/Linux)上,最近安装了 Mono 框架(sudo apt-get install mono-devel
)。
mono --version
给我
Mono JIT compiler version 6.8.0.105 (Debian 6.8.0.105+dfsg-3 Wed Apr 8 15:33:36 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: supported, not enabled.
Suspend: hybrid
GC: sgen (concurrent by default)
然后,我尝试运行mono-test-install
:
Active Mono: /usr/bin/mono
Other Mono executables: /bin/mono
You have a working System.Drawing setup
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at Program.Main () [0x00016] in <70d3c907c7f1453aa373f2b3e2a3a38a>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at Program.Main () [0x00016] in <70d3c907c7f1453aa373f2b3e2a3a38a>:0
在生成的源文件中,有如下代码:
using System;
using System.Reflection;
using System.IO;
class Program {
public static void Main()
{
object watcher = new FileSystemWatcher()
.GetType ()
.GetField ("watcher", BindingFlags.NonPublic | BindingFlags.Static)
.GetValue (null); //Here it fails
Console.WriteLine ("Your file system watcher is: {0}",
watcher != null
? watcher.GetType ().FullName
: "unknown");
}
}
我应该担心吗?
解决方案
推荐阅读
- python - Python try/except 不使用 requests.get() 捕获异常
- xslt - 在 XSLT 中的 xsl:param 中使用双引号
- angular - 在 Angular 应用程序中的事件发射器通知后成功发送网络请求的问题
- typescript - Angular 7 & Stripe 错误 TS2304:找不到名称“Stripe”
- python - 在数据框中查找具有最高均值的行
- php - 如何更新codeigniter中的记录?
- ruby-on-rails - 使用 Apartment 禁用子域
- r - 如何在 Shiny 中绘制反应元素的列
- javascript - 当用户为文本输入选择字体系列时如何触发事件?
- c# - Telerik RadAutoCompleteBox 与动态 ItemSource 问题