我正在使用Newtonsoft.JSON库进行.NET 2.0 C#项目。当我检查web.config文件时,所有程序集都引用2.0版本。
然而,当我在服务器上部署时,我得到了以下错误:
Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 21: }
Line 22:
Line 23: Dictionary<string, string> config = JavaScriptConvert.DeserializeObject<Dictionary<string, string>>(jason);
Line 24:
Line 25: if (Request.Form["login"] == config["adminLogin"] && FormsAuthentication.HashPasswordForStoringInConfigFile(Request.Form["password"], "sha1") == config["adminPass"])
Source File: c:WebsiteWSRecrutTestConnectionPost.aspx Line: 23
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.]
Newtonsoft.Json.Utilities.CollectionUtils.CreateDictionaryWrapper(Object dictionary) in D:NewtonsoftProjectsJsontrunkSrcNewtonsoft.JsonUtilitiesCollectionUtils.cs:422
Newtonsoft.Json.JsonSerializer.CreateObject(JsonReader reader, Type objectType, Object existingValue) in D:NewtonsoftProjectsJsontrunkSrcNewtonsoft.JsonJsonSerializer.cs:223
Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) in D:NewtonsoftProjectsJsontrunkSrcNewtonsoft.JsonJsonSerializer.cs:169
Newtonsoft.Json.JavaScriptConvert.DeserializeObject(String value, Type type, JsonConverter[] converters) in D:NewtonsoftProjectsJsontrunkSrcNewtonsoft.JsonJavaScriptConvert.cs:512
Newtonsoft.Json.JavaScriptConvert.DeserializeObject(String value, JsonConverter[] converters) in D:NewtonsoftProjectsJsontrunkSrcNewtonsoft.JsonJavaScriptConvert.cs:485
Newtonsoft.Json.JavaScriptConvert.DeserializeObject(String value) in D:NewtonsoftProjectsJsontrunkSrcNewtonsoft.JsonJavaScriptConvert.cs:457
ASP.connectionpost_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:WebsiteWSRecrutTestConnectionPost.aspx:23
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +2113547
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.Page.Render(HtmlTextWriter writer) +26
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1896
有人有主意吗?3.5上的组件可能来自哪里?
1,分析器错误消息:无法加载文件或程序集"System.Core,Version=3.5.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089"或其依赖项之一。系统找不到指定的文件。
无论你的目标机器上是否安装了.NET Framework 3.5,我都建议你进行投资。您可以下载一个验证工具来验证目标计算机上的.NET Framework状态。您可以点击以下链接。
http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx
2,警告:程序集绑定日志记录已关闭。
要启用程序集绑定故障日志记录,请将注册表值[HHKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1。
注意:程序集绑定失败日志记录会带来一些性能损失。
要关闭此功能,请删除注册表值
如果它不起作用,您可以根据错误信息修改注册表。
您可以按照以下步骤逐一进行操作。
1、打开"运行"
2,键入"regedit"
3、备份您的注册表
4、在注册表中搜索密钥
5,根据错误信息修改其值
我怀疑您包含了错误的NewtonSoft.Json.dll
库。有多个程序集,其中只有一个支持.NET 2.0。
如果你有Reflector/JustDecomple,你可以验证它是否有一个内部类Newtonsoft.Json.Utilities.LinqBridge
——这就是它不使用System.Core
LINQ方法的原因。
"文件详细信息"的描述中也包含.NET 2.0。
获取此数据的另一个途径是查看异常的详细信息。。。您需要确保调试器正在运行,并在异常时停止以查看详细信息。
所有这一切似乎要么是配置问题(可能都是关于细节的——仔细检查"aspnet_regiis-lk"的输出等所有内容),要么是.NET安装已损坏(但这似乎不太可能)。
否则,
"System.Web.Extensions"是应安装在GAC中的强命名程序集,找不到文件的问题不应由子目录的相对路径问题引起。在我看来,问题在于服务器上没有安装AJAX 1.0扩展。
为了解决这个问题,我们可以从"程序集"部分删除"1.0.61025.0"版本的"System.Web.Extensions"程序集。正如您所说,在这样做之后,LINQ程序集未找到问题出现。对于此问题,我建议检查服务器上是否安装了.NET Framework 3.5。