Bug 31667 - Adding items to Resources/drawable folder causes VS to hang
Summary: Adding items to Resources/drawable folder causes VS to hang
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 3.11 (C5)
Hardware: PC Windows
: Normal normal
Target Milestone: 4.3.0 (C9)
Assignee: Bugzilla
URL:
Depends on: 31519 32845
Blocks:
  Show dependency tree
 
Reported: 2015-07-06 12:44 UTC by Cody Beyer (MSFT)
Modified: 2017-02-16 10:21 UTC (History)
9 users (show)

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

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:
VERIFIED FIXED

Description Cody Beyer (MSFT) 2015-07-06 12:44:09 UTC
### Description

Using the latest versions (see below) of SDK tools and Xamarin.VisualStudio plugin, Visual Studio will become unresponsive when attempting to add item to the Resources/drawable folder.

### Steps to Reproduce

1. Ensure that the installed versions are in parity with those described below
2. Create a new Android app via: "Visual C# -> Android -> Blank App (Android)"
3. Right-click the "Resources\drawable\Icon.png" file and select "Exclude From Project"
4.  Right-click the "drawable" folder to attempt to add back the "Icon.png" file.

### Expected Results

The icon.png file will be removed and then re-added without any issue

### Actual Results

The UI will become inoperable on either steps 3 or 4

### Versions

[Android Items]
Tools: 24.3.3
Platform Tools: 22
Build-tools: 22.0.1

[XVS]

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

Team Explorer for Visual Studio 2013   06177-004-0447006-02634
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0447006-02634
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0447006-02634
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0447006-02634
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0447006-02634
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0447006-02634
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0447006-02634
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Xamarin   3.11.666.0 (ebae43a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.4.16 (5f55a9ef61c11b6ce0890bc91e4c71b1b92be214)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.2.0 (67b390d0d1bd741582cf7b7fd3ffea08583a3f83)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration

[XS]

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 391e84a8-134b-4d8c-a317-3f70c12c3226
Runtime:
	Microsoft .NET 4.0.30319.34014
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 5.1.4 (Business Edition)
Android SDK: C:\Users\codybeyer\AppData\Local\Android\android-sdk
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 17:16:25-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 1 Cody Beyer (MSFT) 2015-07-07 11:46:28 UTC
#### Possible Workaround

In further testing and communications, it appears that the hang only happens the first time that an image is added to a project. Once VS hangs, the task can be ended, and VS reopened, at which point adding images appears to work.

This has not been widely tested, so if you come across this bug report and are having this issue, please reply below with your results and version numbers
Comment 2 Alexander Rojas 2015-07-07 12:42:26 UTC
In my case it doesn’t work, I add the Image, the VS hangs and then I have to end the task, when I open the  VS again the image is in the folder, but it is exclude form the project, when I try to include it the VS hangs again.
Comment 3 Nikola Prokopić 2015-07-10 13:36:27 UTC
I had the same issue with Visual Studio 2015 RC.

Here is my Visual Studio information https://gist.github.com/nprokopic/94ff6b45d9a3811ec72b

Android SDK version: 24.3.2
Android SDK Platform-tools version: 22
Android SDK Build-tools version: 22.0.1

As Cody above said (in comment 1), the task can be ended, and after reopening VS adding resources appears to work. Just in my case, it took me more than an hour to solve the problem. I had to "kill" Visual Studio from the Task Manager multiple times.

So, as a temporary workaround, try to end Visual Studio task (a reasonable number of times) and there is a good chance that you'll fix the issue.
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2015-07-16 17:47:37 UTC
For any other customers who find this bug first when researching this issue, be sure to make special note of the version information (as mentioned in Nikola's comment).

Specifically, you can first confirm that you are either running all of the latest compatible versions:

- Android SDK Tools version 24.3 or higher
- Xamarin for Visual Studio 3.11.586 or higher
- Xamarin Studio 5.9.2.4 or higher


Or all the older compatible versions:

- Android SDK Tools version 24.2 or lower
- Xamarin for Visual Studio 3.11.584 or lower
- Xamarin Studio 5.9.2.2 or lower



## Additional information to add to the bug report

If anyone can reproduce the behavior as described in comment 0 or comment 3, you can try collecting a call stack of Visual Studio's "Main Thread" from the hung instance of VS. I'd be particularly curious to see the call stack from an example where VS hangs the first time, but then succeeds after killing VS and retrying.


You can do this using a second instance of Visual Studio:

1. Start a second instance (a "new window") of Visual Studio.

2. Close any open solutions in the new instance of VS.

3. Select "Debug -> Attach to Process".

4. Select the original hung instance of `devenv.exe` from the list of "Available Processes".

5. Select "Debug -> Break All".

6. Make sure you have the "Debug Location" toolbar is enabled.

7. From the "Thread" drop-down menu in the "Debug Location" toolbar, select the "Main Thread".

8. Open "Debug -> Windows -> Call Stack", select all the lines, copy them, and paste them back into a text file attached on this bug report, or directly in a comment on this bug report.


Thanks!
Brendan
Xamarin Customer Support
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2015-07-30 13:42:56 UTC
Setting as NEEDINFO for now while we're waiting for a thread dump as per comment 4.
Comment 6 Sean Hoffman 2015-07-31 09:42:58 UTC
I am getting the same issue. Both me and my other co-worker. I have tried the above steps in comment 4 for debugging it. I get a "The current thread is not currently running code or the call stack could not be obtained." There is nothing in the call stack.

Haha nvm just tried it again and it seemed to work. Here is the stack trace:

>	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]	
 	mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext)	Unknown
 	mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext)	Unknown
 	mscorlib.dll!System.Threading.WaitHandle.WaitOne()	Unknown
 	Xamarin.AndroidDesigner.dll!Xamarin.AndroidDesigner.JavaProcessConnection.PostMessage(Xamarin.AndroidDesigner.BinaryMessage message, bool checkInitialized)	Unknown
 	Xamarin.AndroidDesigner.dll!Xamarin.AndroidDesigner.JavaProcessConnection.PostMessage(Xamarin.AndroidDesigner.BinaryMessage message)	Unknown
 	Xamarin.AndroidDesigner.dll!Xamarin.AndroidDesigner.DesignerProject.NotifyProjectPathChange(string path, bool isFolder, Xamarin.AndroidDesigner.PathChange change)	Unknown
 	Xamarin.AndroidDesigner.dll!Xamarin.AndroidDesigner.DesignerProject.NotifyProjectFileChange.AnonymousMethod__1b()	Unknown
 	Xamarin.AndroidDesigner.dll!Xamarin.AndroidDesigner.DesignerProject.NotifyResourceDirectoryProcessed()	Unknown
 	Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.MonoAndroidFlavoredProject.OnDesignerUpdate(object sender, System.EventArgs e)	Unknown
 	WindowsBase.dll!System.Windows.Threading.DispatcherTimer.FireTick(object unused)	Unknown
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs)	Unknown
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler)	Unknown
 	WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl()	Unknown
 	WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)	Unknown
 	WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke()	Unknown
 	WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue()	Unknown
 	WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)	Unknown
 	WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)	Unknown
 	WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o)	Unknown
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs)	Unknown
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler)	Unknown
 	WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs)	Unknown
 	WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam)	Unknown


Here is my current version of android, xamarin and android tools.

[Android Items]
Tools: 24.3.3
Platform Tools: 22
Build-tools: 22.0.1

[XVS]
Microsoft Visual Studio Ultimate 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.6.00081

Installed Version: Ultimate

Architecture and Modeling Tools   06181-004-0451022-02210
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2013   06181-004-0451022-02210
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06181-004-0451022-02210
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06181-004-0451022-02210
Microsoft Visual Basic 2013

Visual C# 2013   06181-004-0451022-02210
Microsoft Visual C# 2013

Visual C++ 2013   06181-004-0451022-02210
Microsoft Visual C++ 2013

Visual F# 2013   06181-004-0451022-02210
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06181-004-0451022-02210
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JetBrains ReSharper Ultimate 2015.1.1   Build 102.0.20150521.123255
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2015 JetBrains, Inc.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.60318.734
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

RegexTester   1.0
This is regular extension tester.

SAPReferenceManager   1.0
Manages References to Shared Projects

SQL Server Data Tools   12.0.41012.0
Microsoft SQL Server Data Tools

StyleCop   4.7.49.0
Provides source code style and consistency tools. See http://www.stylecop.codeplex.com/ for more details.

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.11.666.0 (ebae43a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.4.16 (5f55a9ef61c11b6ce0890bc91e4c71b1b92be214)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.2.0 (67b390d0d1bd741582cf7b7fd3ffea08583a3f83)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration


Hope you guys can fix this! It is very annoying.

Thanks,
Sean
Comment 7 Sean Hoffman 2015-07-31 09:45:44 UTC
Btw is there a work around for this? I have some projects that need images for android to run. I really need to get the images in asap.

Thanks,
Sean
Comment 8 Sean Hoffman 2015-07-31 10:05:02 UTC
Just a small update. If I delete all the images in the android folder and then add them again. It will not hang, however none of the images are added the android resource designer thing. So even though the images are in the project I cannot access them in code.

Is there any way to manually regenerate the resource designer thing.

Thanks,
Sean
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2015-08-05 10:59:32 UTC
Thanks for the stack trace.

Based on the stack trace from comment 6, it appears that the fix for Bug 31519 will likely also stop this problem (since VS is hanging in the same method as in Bug 31519).

I will leave as "needinfo" for the moment until a distributable build is available that includes the fix for Bug 31519.
Comment 10 Sean Hoffman 2015-09-09 23:39:21 UTC
So I was having this issue thinking it was the old bug. I checked my build tools version, and it was 24.3.3. So I am guessing it was not the old bug. The way I fixed it is I uninstalled all the old versions of the build tools. This made it work just fine.

So this may be a good work around for others running into this issue.

See ya,
Sean
Comment 11 Sean Hoffman 2015-09-09 23:55:45 UTC
So my comment above was incorrect. I uninstalled the old versions of the Android SDK Build Tools. This seems to allow me to add them fine. In fact I accidentally uninstalled all the build tools, and it allowed me to add the images fine. Then I had to go back and install the latest version of the build tools 23.0.1.

See ya,
Sean
Comment 12 Sean Hoffman 2015-09-10 08:55:44 UTC
SO this worked fine for a single build.

I did a something, not sure what, and it broke the build again. Now I am getting a error only when I run the project. The error only shows in the build output window.

"Error: The operation could not be completed. Invalid pointer"

After some research I found some info that suggested this could be caused by the resource file for android not generating correctly. Since the only thing I changed for the project was the images I decided to try and remove the images and add them again in hopes that what ever was broken would fix itself.

Now when I add the images I get a completely different exception. I get a prompt that states:
Unhandled exception in SignPackage.  See exception for details.

And when you click more details it shows:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Xamarin.VisualStudio.Android.Utilities.BuildProject(Project project, String target, IVsOutputWindowPane outputPane, Exception& ex)

I am not sure if it is related to this issue or not, but not sure what to do or how to fix any of these issues. To think it took me about 3 mins to add images to the ios project. Up to 12 hours to add images into the android project. Who would have thought it was going to be so hard......
Comment 13 Brendan Zagaeski (Xamarin Team, assistant) 2015-09-10 13:37:13 UTC
@Sean, please contact the Support Team via email [1] for some one-on-one troubleshooting of the issues you are seeing. It sounds like you are running into a variety of symptoms that do not directly match the original report. So it will be best to have someone on the Support Team take a look at your specific situation to see what's going on. (Also, you have a Business license or higher, so email support will by default be the best way to get one-on-one troubleshooting help for any future bugs you might run into too.)


Thanks in advance!

[1] https://kb.xamarin.com/customer/portal/articles/1632104-how-do-i-contact-xamarin-for-support-
Comment 14 Juan Marcelo Tondato 2017-02-15 14:53:19 UTC
Hi,
As we've introduced several improvements related to this issues, I'll mark the bug as resolved fixed.
Please feel free to reopen it if you can still reproduce the issue with current bits.
Thanks!
Comment 15 Danish Akhtar 2017-02-16 10:21:00 UTC
I have checked this issue with latest C9 XVS 4.3.0.762 and observed that now this issue is not exists. I am successfully able to remove icon.png file and then re-added without any issue.

Here is the screencast for the same: https://www.screencast.com/t/yxdntUFbD2x

Hence closing this issue. Please feel free to Reopen if you get this issue again.

Thanks!