This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 40982 - [XVS 4.0] VS hangs/freezes when opening solutions containing Android Bindings Libraries that reference other libraries, during `GetAdditionalResourcesFromAssemblies.Execute()`
Summary: [XVS 4.0] VS hangs/freezes when opening solutions containing Android Bindings...
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android (show other bugs)
Version: 4.1.0 (C7)
Hardware: PC Windows
: High major
Target Milestone: 4.1.0 (C7)
Assignee: dean.ellis
Depends on: 36185
  Show dependency tree
Reported: 2016-05-10 02:14 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2016-05-19 18:55 UTC (History)
7 users (show)

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

Test case (12.12 KB, application/zip)
2016-05-10 02:14 UTC, Brendan Zagaeski (Xamarin Support)

Description Brendan Zagaeski (Xamarin Support) 2016-05-10 02:14:54 UTC
Created attachment 15950 [details]
Test case

[XVS 4.0] VS hangs/freezes when opening solutions containing Android Bindings Libraries that reference other libraries, during `GetAdditionalResourcesFromAssemblies.Execute()`

A little complication is that this bug is _very_ closely related to Bug 36185, but the fix for that bug unfortunately did not resolve this slightly different issue. This new bug still occurs consistently in the latest versions, and I have re-verified that my test case for the older Bug 36185 shows no problem on these latest versions.

## Temporary Workaround

Delete the hidden `.vs` folder (VS 2015) or `.suo` file (VS 2013) from the solution directory. The project will then load successfully one more time.

## Regression status: regression between Xamarin 3.11 and Xamarin 4.0

BAD:  XamarinVS   (fb9e9f3) (Cycle 7)
BAD:  XamarinVS   (0dd817c) (Cycle 6 SR 3)
BAD:  XamarinVS  (f860fe4) (Cycle 6)
GOOD: XamarinVS 3.11.1594.0 (a06d6d5) (Cycle 5 SR 5)

## Steps to replicate

1. Open the attached test case. Or you can create a new solution containing 2 "Visual C# > Android > Bindings Library (Android)" projects, and add a project reference from one of the projects to the other.

2. Close the solution.

3. Reopen the solution.

## Results

The Visual Studio window becomes non-responsive (pauses/hangs) for a long time.

### Top of the call stack of the Main Thread

> WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)	Unknown
> mscorlib.dll!System.Threading.SynchronizationContext.InvokeWaitMethodHelper(System.Threading.SynchronizationContext syncContext, System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)	Unknown
> [Native to Managed Transition]	
> [Managed to Native Transition]	
> mscorlib.dll!System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)	Unknown
> mscorlib.dll!System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[] waitHandles, System.TimeSpan timeout, bool exitContext)	Unknown
> Xamarin.Android.Build.Tasks.dll!Xamarin.Android.Tasks.AsyncTask.WaitForCompletion()	Unknown
> Xamarin.Android.Build.Tasks.dll!Xamarin.Android.Tasks.AsyncTask.Execute()	Unknown
> Xamarin.Android.Build.Tasks.dll!Xamarin.Android.Tasks.GetAdditionalResourcesFromAssemblies.Execute()	Unknown
> Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()	Unknown
> Microsoft.Build.dll!Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask()	Unknown
> mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask>(ref Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask stateMachine)	Unknown

## Additional version info (brief)

Microsoft Visual Studio Professional 2015
Version 14.0.24720.00 Update 1
Windows 8 (64-bit) in VMWare Fusion 8.1.1 (3771013) 

The original reporting user also replicated the issue in VS 2015 Update 2 on Windows 10.
Comment 2 Brendan Zagaeski (Xamarin Support) 2016-05-10 03:07:24 UTC
## Rough sketch of the fix

I think the rough idea for how to fix this bug will be to apply approximately the same changes from Bug 36185 to the Android bindings projects targets:

> C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets

For example, I can stop the problem in my local tests by applying the following 2 changes. (As a caution, I haven't tested if this might break the normal _build_ process for bindings projects.)

1. Replace the existing `<Target Name="_BuildAdditionalResourcesCache" ...` element with the following lines:

  <Target Name="_SetupDesignTimeBuildForBuild">
      <DesignTimeBuild Condition=" '$(DesignTimeBuild)' == '' ">false</DesignTimeBuild>

  <Target Name="_SetupDesignTimeBuildForIntellisense" BeforeTargets="_BuildAdditionalResourcesCache">
      <DesignTimeBuild Condition=" '$(DesignTimeBuild)' == '' ">true</DesignTimeBuild>

  <Target Name="_BuildAdditionalResourcesCache"
      Condition=" '$(DesignTimeBuild)' != 'true' "

2. Add "_SetupDesignTimeBuildForBuild;" under the existing `BuildDependsOn` property, so the full element will look like:

Comment 3 dean.ellis 2016-05-10 13:47:39 UTC
Fixed in monodroid/master/4fe81639
Comment 5 xamarin-release-manager 2016-05-13 16:11:40 UTC
Fixed in version (cycle7)

Author: Dean Ellis
Commit: eabab320c9920b69fe55678a471887674bda7300 (xamarin/monodroid)
Included in Commit: d57a3a55c278998a7155163be5fed0b8104f2d1c (xamarin/XamarinVS)
Comment 6 Parmendra Kumar 2016-05-16 13:18:29 UTC
I have checked this issue with latest C7 build: Xamarin.VisualStudio_4.1.0.496_0026d9aaa4328a536c3b00b67972525c8f1982dc and I am still facing same issue. To verify this issue I am using sample project attached in bug description.

Note: I am also checked it with latest master build: Xamarin.VisualStudio_99.0.0.2371_1307d1f050fd15c3abfbd8b865b2f75ff0243ba4 and facing same issue.



Microsoft Visual Studio Enterprise 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01055

Xamarin (0026d9a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (eabab32)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS (0611769)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 8 dean.ellis 2016-05-19 08:14:27 UTC
Fixed in monodroid/cycle7/c479b9e
Comment 9 Atin 2016-05-19 18:55:10 UTC
I have checked this issue with latest build of Cycle 7 i.e. Xamarin.VisualStudio_4.1.0.508_6238fabe2f9d9e35a4ef9a72a0d1df39fbadaf32 and Obsevred that when user Reopen the Solution it opens successfully. VS Does not Hang/Freeze.


Hence I am closing this issue.


Note You need to log in before you can comment on or make changes to this bug.