Bug 20516 - [VS2013 Update 2] Certain project configurations lead to incorrect SUO files and `System.AccessViolationException`
Summary: [VS2013 Update 2] Certain project configurations lead to incorrect SUO files ...
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 3.0
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Brendan Zagaeski (Xamarin Team, assistant)
URL:
: 20429 ()
Depends on:
Blocks:
 
Reported: 2014-06-10 16:52 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2015-09-28 15:08 UTC (History)
8 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample SUO files from "workaround" steps (15.54 KB, application/zip)
2014-06-10 16:52 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2014-06-10 16:52:00 UTC
Created attachment 7036 [details]
Sample SUO files from "workaround" steps

This is an intentional duplicate of Bug #20429 to provide a public bug report, and to confirm that I was able to reproduce the problem.


Related forum thread:
http://forums.xamarin.com/discussion/15803/vs2013-crashing-with-system-accessviolationexception


## Steps to reproduce 

1. Ensure Visual Studio is paired to the Xamarin.iOS build host.

2. Create a new "Visual C# -> Mobile Apps -> Blank App (Xamarin.Forms Portable)" project.

3. Quit Visual Studio.

4. Double click on the solution to open it in Visual Studio.

5. Allow all of the the projects to finish loading.

6. Repeat steps 3-5. You might need to repeat these steps a total of 3 times.


## Result

> Application: devenv.exe
> Framework Version: v4.0.30319
> Description: The process was terminated due to an unhandled exception.
> Exception Info: System.AccessViolationException
> Stack:
>    at Microsoft.VisualStudio.Shell.Interop.IVsSolution4.ReloadProject(System.Guid ByRef)
>    at Xamarin.VisualStudio.ExtensionMethods.Load(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)
>    at Xamarin.VisualStudio.Shell.ShellPackage.<HandleCurrentEntitlements>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)


## "Workaround" / additional result: delete the `.suo` file

Once you've reached the broken state, if you delete the `App1.v12.suo` file, you can repeat steps 3-5 _twice_ successfully.

After opening the project once and then quitting Visual Studio, the `.suo` file is about 66 KB.

The second time, the `.suo` file is about 128 KB.

(Both attached)

The third time, Visual Studio crashes.


## Version information

Visual Studio 2013 Update 2
(Version 12.0.30501.00 Update 2)

Xamarin 3.0.54.0
Xamarin.Android 4.12.4.20
Xamarin.iOS 3.0.54.0

Windows 8.1 64-bit (in VMWare)
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-10 16:56:52 UTC
*** Bug 20429 has been marked as a duplicate of this bug. ***
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-11 01:55:58 UTC
Unfortunately, it looks like this isn't quite as reliably reproducible as it seemed at first.

I have one VM snapshot where I can reproduce the behavior every time, but I tried creating the same Visual  Studio + Xamarin setup starting from an earlier snapshot, and that new setup does _not_ show the problem.

It seems the order of upgrades might be important. Given this result, there's a chance that uninstalling and  reinstalling Xamarin might help.
Comment 3 Tajinder Singh 2014-06-11 04:59:27 UTC
I have checked this issue and able to reproduce this by following the steps mentioned in bug description. Please refer the screencast : http://www.screencast.com/t/BoHuhiGpGj6

Thread Log : https://gist.github.com/saurabh360/48e44ef6383d289c4251

Environment info :

Windows 8.1

Microsoft Visual Studio Professional 2013
Version 12.0.30501.00 Update 2
Microsoft .NET Framework
Version 4.5.51641

Xamarin   3.0.54.0 (d3cf238e3845e930e312b6ec9b4c6c5437c33067)
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-11 13:55:13 UTC
In case there's any trouble reproducing the issue with the steps in the original description, here's another set of steps that produces the same AccessViolationException and stack trace. These steps worked for me in both of my test VM snapshots.


1. Install Team Foundation Server 2013 Update 2, start a trial, and allow the setup wizard to configure the server using the defaults.

2. Create an "Android Application" project (not in source control).

3. Add 3 "Android Class Library" projects to the solution.

4. Save and close the solution.

5. If you don't already have a "Microsoft Visual Studio Scrum 2013.2" team project set up, create one via "File -> New -> Team Project".

6. If you haven't yet configured your workspace mappings for TFS, be sure to do that now.

7. Copy the solution folder from steps 2-3 into the workspace folder for the team project.

8. Open the workspace version of the solution.

9. Right click on the solution in the Solution Explorer and select "Add Solution to Source Control".

10. Quit Visual Studio.

11. Double-click the workspace version of the solution file to re-open it in Visual Studio.


## Result

Visual Studio crashes with exactly the same "AccessViolationException" and stack trace as in the original description.
Comment 5 José Pereira 2014-06-25 12:22:24 UTC
I'm experiencing this same issue.
Deleting the '.suo' before opening a project prevents the visual studio from crashing.
Any updates on this issue?
Comment 7 Paul Diston 2014-06-30 12:21:48 UTC
The work around listed in the following bug seems to help with opening the solution however the issue remains if the solution is opened another way :-

https://bugzilla.xamarin.com/show_bug.cgi?id=20369
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-02 19:50:40 UTC
## Update: unable to reproduce after Xamarin 3.1.215 + Xamarin.iOS 7.2.5.5

I cannot reproduce this error using the steps from comment 0 or comment 4 on recent versions.

Tested on:
Xamarin 3.1.228 + Xamarin.iOS 7.2.5.5
Xamarin 3.3.47 + Xamarin.iOS 7.2.6.28
Xamarin 3.5.55 + Xamarin.iOS 7.4.0.108


I suspect the fix for bug 10670 has made these repro steps ineffective. Bug 10670 was an issue where Visual Studio would automatically reload unloaded projects when it shouldn't have. Perhaps the problematic calls to `IVsSolution4.ReloadProject()` in the stack trace from comment 0 were caused by this incorrect reloading behavior.


As far as I could find, we haven't received any _new_ reports of this problem after Xamarin 3.1.215. We did have one open report of the problem _continuing_ for a user on "the latest release" as of July 8. Those versions would in theory have been:

Xamarin 3.1.215 + Xamarin.iOS 7.2.5.5

I tested the steps from comment 0 and comment 4 on these versions too, but I was not able to reproduce the problem.


There's still a chance that this problem might be hiding somewhere in the current versions. So if any users are able to reproduce this problem with Xamarin 3.5.55 or later, be sure to let us know. If you can provide an updated set of steps to reproduce the problem, that's ideal, but no worries if not.