Visual Studio 2013 crashes consistently when typing in an object/collection initiazlier? - visual-studio-2013

Has anyone else ever seen this happen? I've had Visual Studio crash over and over again when typing in an object initializer: https://msdn.microsoft.com/en-us/library/bb384062.aspx
I suspect it's some kind of Intellisense bug, since it seems to occur only when the space or period key is pressed. I'm really curious what's triggering the sudden and reproducible crash and if there's any patches or workaround to prevent it from occurring.
The image shows where the cursor is when typing within the first set of brackets. This code appears in a method, which implements an interface member for the class.

This appears to have been caused by the "HideShow Comments" extension. I'm still not sure why it occurs, but disabling the plugin stops the crash from occurring and re-enabling the extension causes the crash to occur again. This must be a problem with Visual Studio itself, since it's the only common denominator in all these extension-related crashes.
I attached a debugger and caught the following error:
An unhandled exception of type 'System.NullReferenceException'
occurred in HideShow.Implementation. Additional information: Object
reference not set to an instance of an object.

Related

What is a wil::ResultException and what does it mean to rethrow?

Using UI Automation for some Windows I get the following exceptions on a IUIAutomationElement::FindAll() call using VS2017. First question, what is a wil:ResultException and what does it mean it rethrow at memory address 0? I check the FindAll() result and doesn't seem to have FAILED(hr) because it outputs a debug message if it did and it's not.
Exception thrown at 0x00007FF897AC3E49 in app.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000550AF2BDC0.
Exception thrown at 0x00007FF897AC3E49 in app.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
I don't know if it is related or not. I turned on the fairly new "Use Text cursor indicator" as users are telling us our app can crash when it is on. After doing some testing, I was closing the app and got an access violation deep in UIAutomation.dll. The system was just exiting the process. I was trying to duplicate the crash and though I didn't crash, I just saw this same message and the reply to this post that mentioned UIAutomation. The "fairly" new setting is new to me because our IT just allowed the version update that has the setting on our boxes.
The crash occurred while doing a PeekMessage during the exit of the process. We had a static c++ object that was being deleted and during that call, it called the API. I rearranged the code to make the call that used PeekMessage so it happened before the process exited. That avoided that crash. However, we are MFC based and in a debug build, if any code does an ASSERT during shutdown, MFC's assert code does a PeekMessage to remove WM_QUIT before showing the assert message box. So, we can still crash there randomly in our debug builds.
When running with the Text Cursor Indicator on, I see a lot of these "wil" exceptions in the debug output window (release or debug builds). Many seem to occur when a window that has the indicator drawn over it closes. Example - standard file open dialog. I open it, click the path edit box and when I close the dialog, I get some of those exceptions. Turning off the indicator setting avoids all of that and the crashes.

Visual studio form editor error

I have an error in my form editor preventing me from modifying the form.
I know in which control this occurs but no way to find what exactly causes the problem.
I tried setting breakpoints in the InitializeComponents() of the form I try to open but it doesn't stop (I am in debug mode...). I also tried to attach using a second instant of Visual Studio as demonstrated here, but even when setting all debug exception options to "throw", the attached process doesn't stop and indicate anything about call stack nor other useful information...
All I know is that there is a disposed object I'm trying to access, but absolutely no information as to where in code, etc..
What could I possibly do to debug the situation - knowing which control is the cause but absolutely no idea as to which of the 300 lines of code causes the issue...

Xamarin + Visual Studio 2017 on Android: how debug Exception?

I have taken over a Xamarin.Forms (C#) application from an external source for fixing.
Problem is, that the application does sometimes fail with a runtime error:
System.NullReferenceException: Object reference not set to an instance of an object
The message appears in the output console and in a separate message window in Visual Studio. Unfortunately neither gives any more information about the failed object, a source code line number or a classname, there is just the bare message. Furthermore the "Call Stack" window in Visual Studio is always empty --> I have no easy way to find out where the failure occurs in foreign source code, because virtually no documentation of the program flow exists.
Full source code is available, and I have re-built the application with "Debug" configuration.
Right now the only option I can think of is to scatter breakpoints and Debug.Writelines all over the source code to get an idea where the problem occurs.
Is this really my only option, or did I miss some setting somewhere, so I can retrieve more info, so I can somehow go straight to the code where the failure occurs?
Thx!

visual studio 2015 c# not break on unhandled exception in formload method [duplicate]

I just came across odd behavior with exception handling in .Net. (I'm using C# in MS Visual Studio 2008, but one question I saw here seemed to imply that what I see is true throughout the .Net world.) I am writing a plain WinForm application. I am intentionally causing an unhandled exception to be thrown inside a form_load event handler, outside of any try block. I get no notification. If an unhandled exception occurs in a normal method, a message pops up telling me that the exception happened, and giving me some information about the problem. But in the handler, the code just quietly exits the function without letting anybody know that it happened. If I add a try/catch block, the exception is caught as expected.
Is it true that this behavior happens in all event handlers? And is this expected behavior? And if so, is it because there is too much danger of bad things happening if an event handler unexpectedly stops?
Whether inside or outside VS, this behavior occurs when there is a debugger attached to the process. However, being a debug version makes no difference. If running outside VS without a debugger attached, the unhandled exception will fire up.
You can check
Why the form load can't catch exception? , and
VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows , for possible solutions.
EDIT: This behavior is only specific to the form_load event handler, as far as I know.

Visual Studio not debugging on crash

This is driving me crazy. I'm working on a C# Forms application that is crashing for some reason when calling _documentList.Items.Clear();. For some reason, Visual Studio never catches the crash and it acts as if the application closed without any errors. I'm in the debugger stepping through line by line, and as soon as I hit the _documentList.Items.Clear();, the debugger stops and the form closes. Please help!
Edit: I've found why the app was crashing, but I'm still not sure why the debugger isn't catching it. This should have been much easier to find than it was.
I was trying to update my GUI from a FileSystemWatcher event, so I had to use this.InvokeRequired and this.Invoke(). I'm no longer getting the crash, but I would still like to know why VS isn't catching this in the debugger. My understanding is I should have been getting an exception with the message "Cross-thread operation not valid:"
I think we don't have listbox.Clear() it shopuld be listbox.Items.Clear();
Have you checked if the listbox have items before stepping into the line where you are clearing the items.
Check the items count of listbox.
It appears that this is a known issue and has been fixed when using Tasks in .NET 4.0. See this question (InvokeRequired Exception Handling) for more info.

Resources