VS 2013 Crash When Using JSON Deserialize Method
Asked Answered
G

3

6

I've created a C# ASP.NET method which simply takes a string property containing JSON, both inside the same class. My issue is that whenever I type the .Deserialize method (the commented line) Visual Studio 2013 crashes with an "Unhandled Exception" in event logs.

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

If I write the line in comments (as above) then remove the comments there's no problem so the issue appears to be with Intellisense or the way I'm writing the code - anyone have any ideas?

Crash log

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)

Please let me know if this needs to go onto SuperUser.

Edit 1: Just to confirm this issue occurs during development, not at runtime. VS crashes when I am typing the code.

Edit 2: This issue only occurs with this particular line. The system I'm working with is massive and I've never seen the problem before.

Edit 3: Same issue in a brand new project - potentially a bug in VS 2013 but I don't know what's throwing the exception in the first place.

Gothurd answered 27/3, 2015 at 9:53 Comment(6)
is the same issue when type some other keywords?Paragrapher
No @utility - no it's just this line. I created the instance "js" without an issues. I've written a lot of code in VS 2013 and this is the first time this has happened. Again, sorry for not making this clear above.Gothurd
Same issue if open and re-type in another project?Paragrapher
@utility yes - I created a new project and got the same issue. It's looking more and more like a bug in VS 2013, just an unhandled exception, but I don't know why it's happening in the first place.Gothurd
What extensions have you installed in VS? Try to disable all extension and see if the error persists.Berneta
@Berneta - Disabled all extensions then enabled one by one and it turned out the Bing Developer Assistant was causing the problem. I looked the there was an update which didn't auto install for this extension, I updated it and it works just fine now. Thanks for suggesting this!Gothurd
G
5

As @Jehof suggested in the comments I disabled all of my VS 2013 extensions, which fixed the problem. Enabling each extension one by one showed that the Bing Developer Assistant was causing the problem. There was an update which hasn't installed - installing this update fixed the problem.

To anyone else with such a problem, ensure VS and all extensions are fully updated.

Gothurd answered 27/3, 2015 at 10:27 Comment(1)
Thanks a ton. Bing Developer Assistant was the culprit in my case too. Uninstalling it did the trick.Jobye
P
1

Visual Studio keeps crashing Visual Studio when working with TBS and Angular JS.

System.NullReferenceException was unhandled

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

IntelliSense uses large amounts of memory on medium/large projects which can result in crashes and instability - you can turn off completions in Tools/Options/Text Editor/Node.js/Statement completion/Auto list members to avoid this (recommended).

Paragrapher answered 27/3, 2015 at 10:26 Comment(2)
Thanks for your comment. As specified in my answer the issue was caused by Bing Developer Assistant but you highlight a good point about memory - it's possible that Bing was using more than it's fair share, causing the application exception.Gothurd
you can mark as helpful if it helped to sort the errorsParagrapher
A
-1

You can not use "object", you must use a type.

Deserialize<T>()

, where T is a type, cannot be "object"

Adequacy answered 27/3, 2015 at 10:59 Comment(1)
object is a valid type, but as my question specified this issue occured during development, not runtime. Once I fixed the issue my code ran perfectly.Gothurd

© 2022 - 2024 — McMap. All rights reserved.