小编Kal*_*ton的帖子

使用JSON反序列化方法时VS 2013崩溃

我创建了一个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;
}
Run Code Online (Sandbox Code Playgroud)

如果我在评论中写下这一行(如上所述)然后删除评论没有问题,所以问题似乎是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, …
Run Code Online (Sandbox Code Playgroud)

.net c# javascriptserializer visual-studio-2013

6
推荐指数
1
解决办法
583
查看次数