8

Newtonsoft.Json.dllライブラリをモノラルで使用するプログラムをコンパイルしようとしています

コンパイルコマンド

gmcs Program.cs etcetera.cs -r:Newtonsoft.Json.dll -r:Argotic.Core.dll

結果:

Missing method .ctor in assembly Newtonsoft.Json.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
Can't find custom attr constructor image: Newtonsoft.Json.dll mtoken: 0x0a000053

そして、プログラム(mono Program.exe)を実行しようとすると、エラーがスローされます。

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Newtonsoft.Json'.

  at my_program.CJSONStuff.serialize (System.Collections.Generic.Dictionary`2 obj) [0x00000] in <filename unknown>:0 

  at my_program.TheObjDB.getAllSerialized () [0x00000] in <filename unknown>:0 

  at my_program.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Newtonsoft.Json'.

  at my_program.CJSONStuff.serialize (System.Collections.Generic.Dictionary`2 obj) [0x00000] in <filename unknown>:0 

  at my_program.TheObjDB.getAllSerialized () [0x00000] in <filename unknown>:0 

  at my_program.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

私はこれまでmonoを使用したことがなく、何が起こっているのかわかりません。しかし、おそらくこれは、DLLもmonoでコンパイルされていないため、使用できないことを意味しますか?だとしたら; これは、ソースコードも持っていない限り、モノラルでサードパーティのDLLを使用できないことを意味しますか?

4

1 に答える 1

6

デフォルトのmonoはv2.0ランタイムを使用しますが、nugetはv4.0を使用しているためです。これは、monoでランタイムパラメータを定義することで解決できます。

mono --runtime=v4.0.30319 NuGet.exe

ソース: http: //monomvc.wordpress.com/2012/03/06/nuget-on-mono/

于 2012-07-22T12:38:29.553 に答える