Bug 9132 - TargetInvocationException when editing XML drawables
Summary: TargetInvocationException when editing XML drawables
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: 4.6.x
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: Lluis Sanchez
URL:
: 5262 5601 6790 10625 ()
Depends on:
Blocks:
 
Reported: 2012-12-25 16:40 UTC by Benny
Modified: 2013-03-20 07:11 UTC (History)
9 users (show)

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


Attachments
Screenshot with error (128.59 KB, image/png)
2012-12-25 16:40 UTC, Benny
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 or GitHub 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 Benny 2012-12-25 16:40:54 UTC
Created attachment 3130 [details]
Screenshot with error

When editing an existing xml-drawable that is currently or recently was in use by a view, I get the following error when trying to save my changes:  http://tinypic.com/m/fw2hiv/2 (or see attachment)

Steps to Reproduce:
- start a new android application solution
- create a new xml-drawable, save and attach to a view in your layout.axml
- make some changes in the drawable.xml

8/10 times I get the above mentioned exception, sometimes I also get the same exception when trying to delete such a file.
A fix I found was to unlock the files using unlocker (http://tinypic.com/m/fw2hk9/2)
but when fine-tuning a stroke or an alpha-value, it's quite a nuisance to go through so many steps.

Mono is up to date, I'm on Windows7.
Comment 1 janpieter.minderhoud 2013-01-25 02:55:46 UTC
Confirmed.
Running Windows 8
Version info see below.

I can reproduce this error even after a system reboot and having NO layout's or other drawables open (or opened), after MonoDelelop startup, that use the drawable.xml in question.

It seems to only happen with XML drawables defining a <layer-list>.
<shape> and <selector> drawables seem to work fine.

Most of the time I'm able to save the drawable once or twice before the error appears.

Because of this I've started editing drawables in an other editor.

Regards,
J-P

----------------------------------------------------------------
MonoDevelop 3.0.6

Installation UUID: 015541ff-3550-4c36-a07d-053f90cf42a7

Runtime:

	Microsoft .NET 4.0.30319.18033

	GTK 2.16.6

	GTK# (2.12.0.0)

Mono for Android: 4.4.54

Android SDK: C:\Users\...\AppData\Local\Android\android-sdk

	Supported Android versions:

		2.1 (API level 7)

		2.2 (API level 8)

		2.3 (API level 10)

		3.1 (API level 12)

		4.0 (API level 14)

		4.1 (API level 16)

		4.2 (API level 17)

Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31

No build info

Operating System:

	Windows 6.2.9200.0 (64-bit)
----------------------------------------------------
Comment 2 Dave Wolfe 2013-02-28 20:10:20 UTC
I'm also getting this error in Xamarin Studio/MonoDevelop 4.0.  It's happening with <shape> as well as <layer-list>. Using Windows 7.
Comment 3 Lluis Sanchez 2013-03-13 05:46:13 UTC
*** Bug 10625 has been marked as a duplicate of this bug. ***
Comment 4 Lluis Sanchez 2013-03-13 07:53:50 UTC
*** Bug 5601 has been marked as a duplicate of this bug. ***
Comment 5 Lluis Sanchez 2013-03-13 07:55:15 UTC
*** Bug 5262 has been marked as a duplicate of this bug. ***
Comment 6 Lluis Sanchez 2013-03-13 07:57:44 UTC
*** Bug 6790 has been marked as a duplicate of this bug. ***
Comment 7 Lluis Sanchez 2013-03-15 05:57:24 UTC
It turns out that the Android SDK is not explicitly closing resource files after parsing them. This seems to be fixed in Jelly Bean, although we have not yet integrated the Jelly Bean layout renderer yet (the sdk api has many changes, so it requires new important integration work). And even if we did the files would still be locked when choosing a framework other than Jelly Bean to display the layout in the designer.

This problem can also reproduced in Eclipse, although it doesn't happen so often there, I guess because the garbage collector is running more often. I've now added code to run the garbage collector more often and that seems to solve the problem (although there is no guarantee that it will always work). Right now that's all I can do since we depend on the Android SDK behavior here.
Comment 8 Jatin 2013-03-20 07:11:33 UTC
Today with the latest builds:

XS 4.0.2.22
VS 2012/2010
MFA 4.6.01073
Mono 2.10.12

This issue does not exist, as now the exception does not appear when edit the layout axml file.

Hence, closing this issue.