【问题标题】:VS 2013 Crash When Using JSON Deserialize MethodVS 2013 使用 JSON 反序列化方法时崩溃
【发布时间】:2015-03-27 09:53:16
【问题描述】:

我创建了一个 C# ASP.NET 方法,它只接受一个包含 JSON 的字符串属性,两者都在同一个类中。我的问题是,每当我键入 .Deserialize 方法(注释行)时,Visual Studio 2013 就会崩溃,并在事件日志中显示“未处理的异常”。

public object JSONAsObject()
{
    object obj = new object();
    JavaScriptSerializer js = new JavaScriptSerializer();
    // obj = js.Deserialize<object>(this._json);
    return obj;
}

如果我在 cmets 中编写该行(如上)然后删除 cmets 没有问题,所以问题似乎与 Intellisense 或我编写代码的方式有关 - 有人有什么想法吗?

崩溃日志

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException
Stack:
   at System.Text.RegularExpressions.Regex.Escape(System.String)
   at Microsoft.OneCode.Utilities.UserControl.CodeSnippetsTextBox.UpdateRegex()
   at Microsoft.OneCode.Utilities.UserControl.CodeSnippetsTextBox.OnMyWorkCollectionChanged(System.Object, System.Collections.Specialized.NotifyCollectionChangedEventArgs)
   at System.Collections.ObjectModel.ObservableCollection`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs)
   at System.Collections.ObjectModel.ObservableCollection`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].InsertItem(Int32, System.__Canon)
   at System.Collections.ObjectModel.Collection`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Add(System.__Canon)
   at Microsoft.OneCode.IntellisensePresenter.ViewModel.IntellisenseViewModel.UpdateCodeSnippets(System.Collections.Generic.IEnumerable`1<Microsoft.OneCode.DataModel.CodeSearchResult>)
   at Microsoft.OneCode.IntellisensePresenter.ViewModel.IntellisenseViewModel+<>c__DisplayClass5.<SearchCode>b__2()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)

如果这需要进入超级用户,请告诉我。

编辑 1: 只是为了确认这个问题发生在开发过程中,而不是在运行时。输入代码时 VS 崩溃。

编辑 2: 此问题仅发生在此特定行中。我正在使用的系统非常庞大,我以前从未见过这个问题。

编辑 3: 一个全新项目中的相同问题 - 可能是 VS 2013 中的错误,但我不知道是什么首先引发了异常。

【问题讨论】:

  • 键入其他关键字时是否同样的问题?
  • 没有@utility - 不,它只是这一行。我创建了没有问题的实例“js”。我在 VS 2013 中编写了很多代码,这是第一次发生这种情况。再次,很抱歉没有在上面说清楚。
  • 如果在另一个项目中打开并重新输入同样的问题?
  • 你在VS中安装了哪些扩展?尝试禁用所有扩展,看看错误是否仍然存在。
  • @Jehof - 禁用所有扩展,然后一一启用,结果是 Bing 开发人员助手导致了问题。我看了有一个没有自动安装这个扩展的更新,我更新了它,它现在工作得很好。感谢您提出这个建议!

标签: c# .net visual-studio-2013 javascriptserializer


【解决方案1】:

正如@Jehof 在 cmets 中建议的那样,我禁用了所有 VS 2013 扩展,从而解决了问题。逐个启用每个扩展程序表明 Bing Developer Assistant 导致了问题。有一个尚未安装的更新 - 安装此更新解决了问题。

对于遇到此类问题的其他人,请确保 VS 和所有扩展都已完全更新。

【讨论】:

  • 非常感谢。 Bing Developer Assistant 也是我的罪魁祸首。卸载它就可以了。
【解决方案2】:

Visual Studio 在使用 TBS 和 Angular JS 时不断使 Visual Studio 崩溃。

System.NullReferenceException was unhandled

Additional information: Object reference not set to an instance of an object.

IntelliSense 在中型/大型项目上使用大量内存,这可能导致崩溃和不稳定 - 您可以在工具/选项/文本编辑器/Node.js/语句完成/自动列表成员中关闭完成以避免这种情况(推荐)。

【讨论】:

  • 感谢您的评论。正如我在回答中所指出的,问题是由 Bing 开发人员助手引起的,但您强调了一个关于内存的好点 - 必应使用的内存可能超出其公平份额,从而导致应用程序异常。
  • 如果它有助于对错误进行排序,您可以将其标记为有帮助
【解决方案3】:

不能使用“对象”,必须使用类型。

Deserialize<T>()

,其中 T 是一个类型,不能是“对象”

【讨论】:

  • object 是一个有效的类型,但正如我的问题所指出的,这个问题发生在开发过程中,而不是运行时。一旦我解决了这个问题,我的代码就可以完美运行了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-02-05
  • 2015-09-22
  • 1970-01-01
  • 2016-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多