次のクラスがあり、Mono(Macの場合)を使用してネイティブコードからC#にいくつかの実行ループ呼び出しをマップしますが、コンパイラーが機能せず、コンパイルしようとすると常にクラッシュします。このクラスのみを含む別のプロジェクトに削除しましたが、まだ壊れているため、このコードに特に問題があるようです。
誰かがこのようなものを見たことがありますか?
using System;
using System.Threading;
namespace Integration.Mac
{
public class CommonRunLoop
{
static IntPtr runLoopReference;
public static IntPtr CommonRunLoopReference {
get {
return runLoopReference;
}
}
static CommonRunLoop() {
AutoResetEvent lockObj = new AutoResetEvent (true);
Thread runLoop = new Thread (delegate() {
runLoopReference = CFRunLoopGetCurrent ();
lockObj.Set ();
CFRunLoopRun ();
});
runLoop.IsBackground = true;
runLoop.Name = "Common-Sync-Run-Loop";
lockObj.WaitOne();
}
[DllImport ("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")]
extern static IntPtr CFRunLoopGetCurrent ();
[DllImport ("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")]
extern static IntPtr CFRunLoopGetMain ();
[DllImport ("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")]
extern static void CFRunLoopRun ();
}
}
コンパイラの出力は次のとおりです。
ソリューションの構築:calling-native-code-mono(デバッグ)
ビルド:calling-native-code-mono(デバッグ)メインコンパイルを実行しています... / Library / Frameworks / Mono.framework / Versions / 2.10.9 / bin / dmcs / noconfig "/ out:/ Users / mauricio / Projects / calling -native-code-mono / bin / Debug / calling-native-code-mono.dll "" /r:/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/4.0/System.dll " "/r:/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/4.0/System.Core.dll" / nologo / warn:4 / debug:full / optimize- / codepage:utf8 "/ define:DEBUG "/t:library" /Users/mauricio/Projects/calling-native-code-mono/CommonRunLoop.cs "" /Users/mauricio/Projects/calling-native-code-mono/AssemblyInfo.cs "
未処理の例外:System.NullReferenceException:オブジェクト参照がMono.CSharp.EmitContext.Emit(OpCode opcode、Mono.CSharp.MethodSpecメソッド)[0x00000]のオブジェクトのインスタンスに設定されていません:0のMono.CSharp.New.Emit (Mono.CSharp.EmitContext ec、IMemoryLocation target)[0x00000] in:0 at Mono.CSharp.VariableReference.EmitAssign(Mono.CSharp.EmitContext ec、Mono.CSharp.Expression source、Boolean Leave_copy、Boolean prepare_for_load)[0x00000] in :0 at Mono.CSharp.Assign.Emit(Mono.CSharp.EmitContext ec、Boolean is_statement)[0x00000] in:0 at Mono.CSharp.Assign.EmitStatement(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at MonoCSharp.Block.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit( Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in: 0
at Mono.CSharp.TypeContainer.EmitType()[0x00000] in:0 at Mono.CSharp.ModuleContainer.Emit()[0x00000] in:0 at Mono.CSharp.AssemblyDefinition.Emit()[0x00000] in:0 at Mono .CSharp.Driver.Compile()[0x00000] in:0 at Mono.CSharp.Driver.Main(System.String [] args)[0x00000] in:0 [ERROR] FATAL UNHANDLED EXCEPTION:System.NullReferenceException:Object reference not Mono.CSharp.EmitContext.Emit(OpCode opcode、Mono.CSharp.MethodSpec method)[0x00000] in:0 at Mono.CSharp.New.Emit(Mono.CSharp.EmitContext ec、IMemoryLocation target )[0x00000] in:0 at Mono.CSharp.VariableReference.EmitAssign(Mono.CSharp.EmitContext ec、Mono.CSharp.Expression source、Boolean Leave_copy、Boolean prepare_for_load)[0x00000] in:0 at Mono.CSharp.Assign.Emit (Mono.CSharp。EmitContext ec、Boolean is_statement)[0x00000] in:0 at Mono.CSharp.Assign.EmitStatement(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec) [0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock .Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in:0BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.DoEmit(Mono。 CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[ 0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in:0BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.DoEmit(Mono。 CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[ 0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in:00 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0atMono.CSharp。 Constructor.Emit()[0x00000] in:00 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0atMono.CSharp。 Constructor.Emit()[0x00000] in:0
at Mono.CSharp.TypeContainer.EmitType()[0x00000] in:0 at Mono.CSharp.ModuleContainer.Emit()[0x00000] in:0 at Mono.CSharp.AssemblyDefinition.Emit()[0x00000] in:0 at Mono .CSharp.Driver.Compile()[0x00000] in:0 at Mono.CSharp.Driver.Main(System.String [] args)[0x00000] in:0未処理の例外:System.NullReferenceException:オブジェクト参照がMono.CSharp.EmitContext.Emit(OpCode opcode、Mono.CSharp.MethodSpecメソッド)[0x00000]のオブジェクトのインスタンスに設定されていません:0のMono.CSharp.New.Emit (Mono.CSharp.EmitContext ec、IMemoryLocation target)[0x00000] in:0 at Mono.CSharp.VariableReference.EmitAssign(Mono.CSharp.EmitContext ec、Mono.CSharp.Expression source、Boolean Leave_copy、Boolean prepare_for_load)[0x00000] in :0 at Mono.CSharp.Assign.Emit(Mono.CSharp.EmitContext ec、Boolean is_statement)[0x00000] in:0 at Mono.CSharp.Assign.EmitStatement(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at MonoCSharp.Block.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit( Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in: 0
at Mono.CSharp.TypeContainer.EmitType()[0x00000] in:0 at Mono.CSharp.ModuleContainer.Emit()[0x00000] in:0 at Mono.CSharp.AssemblyDefinition.Emit()[0x00000] in:0 at Mono .CSharp.Driver.Compile()[0x00000] in:0 at Mono.CSharp.Driver.Main(System.String [] args)[0x00000] in:0 [ERROR] FATAL UNHANDLED EXCEPTION:System.NullReferenceException:Object reference not Mono.CSharp.EmitContext.Emit(OpCode opcode、Mono.CSharp.MethodSpec method)[0x00000] in:0 at Mono.CSharp.New.Emit(Mono.CSharp.EmitContext ec、IMemoryLocation target )[0x00000] in:0 at Mono.CSharp.VariableReference.EmitAssign(Mono.CSharp.EmitContext ec、Mono.CSharp.Expression source、Boolean Leave_copy、Boolean prepare_for_load)[0x00000] in:0 at Mono.CSharp.Assign.Emit (Mono.CSharp。EmitContext ec、Boolean is_statement)[0x00000] in:0 at Mono.CSharp.Assign.EmitStatement(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec) [0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock .Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in:0BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.DoEmit(Mono。 CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[ 0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in:0BlockVariableDeclaration.DoEmit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Statement.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.DoEmit(Mono。 CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Block.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[ 0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.Constructor.Emit()[0x00000] in:00 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0atMono.CSharp。 Constructor.Emit()[0x00000] in:00 at Mono.CSharp.ExplicitBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0 at Mono.CSharp.ToplevelBlock.Emit(Mono.CSharp.EmitContext ec)[0x00000] in:0atMono.CSharp。 Constructor.Emit()[0x00000] in:0
at Mono.CSharp.TypeContainer.EmitType()[0x00000] in:0 at Mono.CSharp.ModuleContainer.Emit()[0x00000] in:0 at Mono.CSharp.AssemblyDefinition.Emit()[0x00000] in:0 at Mono .CSharp.Driver.Compile()[0x00000] in:0 at Mono.CSharp.Driver.Main(System.String [] args)[0x00000] in:0ビルド完了-1エラー、0警告- - - - - - - - - - - 終わり - - - - - - - - - - -
ビルド:1エラー、0警告