2012-04-11 9 views
1

モノトゥッチ/ iOS開発の新機能です。私は使用していますニュートンソフトのモノトゥッチは機能しません。

========== 
MonoDevelop 2.8.8.4 
Installation UUID: 0d3db625-7df9-4282-9aa6-177c25a46d07 
Runtime: 
     Mono 2.10.9 (tarball Tue Mar 20 15:31:37 EDT 2012) 
     GTK 2.24.10 
     GTK# (2.12.0.0) 
Mono for Android not installed 
Apple Developer Tools: 
     Xcode 4.2.1 (834) 
     Build 4D502 
Monotouch: 5.2.10 (Evaluation) 
========== 

私はNewtonsoft 3.5を使用してjson文字列にオブジェクトをシリアル化しようとしています。

非常に簡単なコードが、動作していない...誰も私を助けてくださいことができ...

以上
partial void Action_Clicked (MonoTouch.Foundation.NSObject sender) 
{ 
    myDTO test = new myDTO(); 
    string teststring = ObjToJSON(test); 
} 

public string ObjToJSON(myDTO oObject) //Old function name is ObjToJSON_WithWrapper 
{ 
    string sJSON = ""; 
    sJSON = Newtonsoft.Json.JsonConvert.SerializeObject(oObject); 
    return sJSON; 
} 

public myDTO JSONToObj(String JSONString) //Old function name is JSONToObjNew 
{ 
    myDTO deseri = JsonConvert.DeserializeObject<myDTO>(JSONString); 
    return deseri; 
} 

public class myDTO 
{ 
    public myDTO() 
    { 
    } 

    public string StringObject {get; set;} 
} 

が私の簡単なテストコードですが、それはNewtonsoft.Json.JsonConvert.SerializeObject(実行だとき、それは私にエラーを与えていますoObject);

*** ERROR*** 

{System.TypeLoadException: A type load exception has occurred. 
    at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Type,System.Type].AddValue System.Type key) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Type,System.Type].Get (System.Type key) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAssociatedMetadataType (System.Type type) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute[JsonContainerAttribute] (System.Type type) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.JsonTypeReflector.GetAttribute[JsonContainerAttribute] (ICustomAttributeProvider attributeProvider) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Reflection.ICustomAttributeProvider,Newtonsoft.Json.JsonContainerAttribute].AddValue (ICustomAttributeProvider key) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Utilities.ThreadSafeStore`2[System.Reflection.ICustomAttributeProvider,Newtonsoft.Json.JsonContainerAttribute].Get (ICustomAttributeProvider key) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.CachedAttributeGetter`1[Newtonsoft.Json.JsonContainerAttribute].GetAttribute (ICustomAttributeProvider type) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonContainerAttribute (System.Type type) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonObjectAttribute (System.Type type) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (System.Object value) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <filename unknown>:0 
    at JSONTest1.JSONTest1ViewController.ObjToJSON (JSONTest1.myDTO oObject) [0x00006] in /Users/developer/Projects/JSONTest1/JSONTest1/JSONTest1ViewController.cs:61 
    at JSONTest1.JSONTest1ViewController.Action_Clicked (MonoTouch.Foundation.NSObject sender) [0x00006] in /Users/developer/Projects/JSONTest1/JSONTest1/JSONTest1ViewController.cs:52 at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) 
    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
    at JSONTest1.Application.Main (System.String[] args) [0x00000] in /Users/developer/Projects/JSONTest1/JSONTest1/Main.cs:17 } 

答えて

3

あなたはMonoTouchでのためNewtonsoftのこのバージョンが必要です。迅速な応答を

https://github.com/ayoung/Newtonsoft.Json

+0

感謝を。私はこのバージョンをダウンロードしましたが、それはソリューションファイルを含んでいます。私はどのように私がモノで使うことができる.dllファイルを生成することができるのか分かりません... – Kartik

+0

非常に非常にありがとう..助けてください...もう一度ありがとう.. – Kartik

関連する問題