This project has moved. For the latest updates, please go here.
1

Closed

Causing Visual Studio to crash when exiting

description

If I close Visual Studio 2012 with a Solution currently open, Settings Switcher causes Visual Studio to crash prior to it exiting. Disabling Settings Switcher resolves the issue. Visual Studio crashing results in the following dialog:

Image

Upon completion if I Debug the error in a new instance of Visual Studio, I can retrieve the following error details, with Stack Trace:
System.Runtime.InteropServices.COMException was unhandled
  HResult=-2147417848
  Message=The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))
  Source=EnvDTE
  ErrorCode=-2147417848
  StackTrace:
       at EnvDTE.DTEClass.get_Solution()
       at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.get_CurrentSolutionSettingsFile()
       at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.LoadSettingsFiles(Boolean ignoreSolutionSettingsFile)
       at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.SettingsFileDeletedCreatedChangedOrRenamed(Object sender, EventArgs e)
       at System.IO.FileSystemWatcher.OnChanged(FileSystemEventArgs e)
       at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
       at System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* overlappedPointer)
       at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
  InnerException: 
If I don't Debug it, it ends up restarting Visual Studio (since it crashed):

Image

I also see similar details in the Windows Event Logs:
Log Name:      Application
Source:        .NET Runtime
Date:          6/18/2014 8:13:52 AM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      (obfuscated)
Description:
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException
Stack:
   at EnvDTE.DTEClass.get_Solution()
   at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.get_CurrentSolutionSettingsFile()
   at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.LoadSettingsFiles(Boolean)
   at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.SettingsFileDeletedCreatedChangedOrRenamed(System.Object, System.EventArgs)
   at System.IO.FileSystemWatcher.OnChanged(System.IO.FileSystemEventArgs)
   at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32, System.String)
   at System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name=".NET Runtime" />
    <EventID Qualifiers="0">1026</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2014-06-18T12:13:52.000000000Z" />
    <EventRecordID>18191</EventRecordID>
    <Channel>Application</Channel>
    <Computer>(obfuscated)</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException
Stack:
   at EnvDTE.DTEClass.get_Solution()
   at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.get_CurrentSolutionSettingsFile()
   at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.LoadSettingsFiles(Boolean)
   at DaveSexton.SettingsSwitcher.Vsix.SettingsSwitcherPackage.SettingsFileDeletedCreatedChangedOrRenamed(System.Object, System.EventArgs)
   at System.IO.FileSystemWatcher.OnChanged(System.IO.FileSystemEventArgs)
   at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32, System.String)
   at System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
</Data>
  </EventData>
</Event>
One possibly notable detail is that my Visual Studio Settings reside on a network drive (like \\NetworkServerName\User\MyName\My Documents\Visual Studio 2012\Settings) as opposed to the local disk. I'm not entirely certain of the timing of this issue, but I do know that it has been since I upgraded to Settings Switcher 1.1.

Let me know if there are any additional details that may help.
Closed Jun 28, 2014 at 12:01 AM by davedev
Fixed in v1.2.

comments

davedev wrote Jun 18, 2014 at 3:29 PM

Thank you for reporting this bug.

I will try to fix it for the next release. However, since I cannot reproduce the problem myself, it would be great if you could let me know whether the new version solves the problem.

davedev wrote Jun 18, 2014 at 3:44 PM

Actually, there is one thing you could do to help: If you could break on the error again, please let me know whether the SettingsSwitcherPackage's unloadingPackage field is true?

wrote Jun 18, 2014 at 6:01 PM

grinndaddy wrote Jun 20, 2014 at 1:18 PM

I see that the SettingsSwitcherPackage class has an unloadingPackage property (by hitting SettingsSwitcherPackage.unloadingPackage from the Immediate Window) but I can't actually step into the code in the debugger to find the respective instance of SettingsSwitcherPackage to get the value since I don't have the pdb (or source?) for the compiled code - unless you know something that I don't know. But, I'd be happy to try out the new version when it comes out, or even before you release it if you like.

Oddly, reproducing the issue is now sporadic. It's funny how a bug never rears its ugly head when you want it to. If you have any ideas to try to reproduce it consistently, I'm open to suggestions. I've tried it with files in the solution open, closed, edited and saved, and switching the applied vssettings before closing all at no avail.

davedev wrote Jun 20, 2014 at 3:37 PM

Without the pdb/source you could still use WinDbg if you're familiar with it, but it's no problem if you can't. I'll assume that field is true at the point of failure and simply avoid loading settings in the file change event handler. Perhaps I'll release it as a beta.

Thanks again for your feedback.

davedev wrote Jun 20, 2014 at 3:48 PM

Maybe you could repro fairly consistently by triggering a change to the Settings directory while closing Visual Studio; e.g., by adding a dummy .vssettings file. It's still a race condition though.

davedev wrote Jun 21, 2014 at 5:28 PM

I've uploaded a debug build of v1.2 to my website:
http://davesexton.com/Downloads/VSSwitch-Debug/DaveSexton.SettingsSwitcher-1.2-Debug.zip

I'd really appreciate it if you would test it out and let me know whether it does or doesn't fix the problem.

If it does, then I'll release it to production.

Thanks,
Dave

grinndaddy wrote Jun 23, 2014 at 7:20 PM

I've installed 1.2 and don't seem to be able to reproduce the issue but as I mentioned it's been a bit "flaky" as of late. I did have the issue occur earlier today, prior to installing 1.2. If you don't hear from me within the next 'couple of days then I'd say that the fix was successful.

davedev wrote Jun 23, 2014 at 8:06 PM

Great, thanks!

wrote Jun 28, 2014 at 12:01 AM