我想反序列化一個由JSON.Net 4.0 r3本身序列化的JSON字符串。序列化和反序列化的設置相同。會出現以下情況例外:BindingFailure通過JSON.Net 4.0反序列化r3
找不到類型 'System.Collections.Generic.List`1 [[System.Drawing.PointF, System.Drawing中]]' 在組件「」 mscorlib程序,版本= 4.0 .0.0, 文化=中性公鑰= b77a5c561934e089" 」
接通後‘停止時BindingFailure拋出’,我看到的問題是在以下的部分(JSON.Net源代碼,DefaultSerializationBinder.cs) :
if (assemblyName != null)
{
Assembly assembly;
#if !SILVERLIGHT && !PocketPC
// look, I don't like using obsolete methods as much as you do but this is the only way
// Assembly.Load won't check the GAC for a partial name
#pragma warning disable 618,612
assembly = Assembly.LoadWithPartialName(assemblyName);
#pragma warning restore 618,612
#else
assembly = Assembly.Load(assemblyName);
#endif
if (assembly == null)
throw new JsonSerializationException("Could not load assembly '{0}'.".FormatWith(CultureInfo.InvariantCulture, assemblyName));
Type type = assembly.GetType(typeName); // BindingFailure here
if (type == null)
throw new JsonSerializationException("Could not find type '{0}' in assembly '{1}'.".FormatWith(CultureInfo.InvariantCulture, typeName, assembly.FullName));
}
在BindingFailure的點示出的錯誤是
與顯示名稱「System.Drawing中」的組件未能在 「LoadFrom」加載結合的AppDomain的上下文ID爲1的 的原因失敗是:System.IO.FileNotFoundException:無法加載文件 或程序集「System.Drawing」或它的一個依賴項。系統 找不到指定的文件。
操作系統是Windows 7,64位。我正在使用Visual Studio 2010並將此應用程序定位到Framework v4。目標不是Silverlight或PocketPC。
爲什麼在這種情況下無法加載「System.Drawing」?我應該從哪裏開始調查這是JSON.Net問題還是我的Framework 4.0安裝問題?
在此先感謝。