Bug 6990 - visual studio crashes when opening designer files
Summary: visual studio crashes when opening designer files
Status: RESOLVED DUPLICATE of bug 7149
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-07 10:52 UTC by tophathacker
Modified: 2016-08-03 15:23 UTC (History)
13 users (show)

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


Attachments
Layout that crashed every time I open it in VS2010 (2.04 KB, application/octet-stream)
2012-09-30 18:42 UTC, Robert Ellison
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 DUPLICATE of bug 7149

Description tophathacker 2012-09-07 10:52:57 UTC
opening any axml file crashes visual studio

visual studio 2010, r1
reinstalled mono for android from scratch
made new axml files, still crashes visual studio
Comment 1 Robert Ellison 2012-09-30 18:41:56 UTC
Mono for Android 4.2.6 installed. Editing a resource file worked for a while and now crashes Visual Studio 2010 SP1 every time I open it. I'll attach the file that is crashing.
Comment 2 Robert Ellison 2012-09-30 18:42:29 UTC
Created attachment 2656 [details]
Layout that crashed every time I open it in VS2010
Comment 3 Conor O'Doherty 2012-10-02 08:18:41 UTC
AXML designer crashes visual studio with null exception

The following exception is throw when opening an axml file in the visual designer. When I close the exception window, visual studio crashes and reopens.



Exception Type: System.NullReferenceException
Exception Message: Object reference not set to an instance of an object.
Exception Stack Trace:    at Xamarin.AndroidDesigner.Layouts.TableRow.AddMissingPlaceholders(Int32 ncols)
   at Xamarin.AndroidDesigner.Layouts.TableLayout.InitializeForDesigner()
   at Xamarin.AndroidDesigner.AndroidDesignerItem.InitializeForDesigner()
   at Xamarin.AndroidDesigner.AndroidDesignerSession.InitializeItem(AndroidDesignerItem item)
   at Xamarin.AndroidDesigner.AndroidDesignerSession.InitLayoutXml(LayoutInfo layout)
   at Xamarin.AndroidDesigner.AndroidDesignerSession.LoadLayoutXml(String path)
   at Xamarin.AndroidDesigner.AndroidDesignerSession.InitSession()
   at Xamarin.AndroidDesigner.AndroidDesignerSession.DoRefresh(Boolean asyncRefresh)
   at Xamarin.AndroidDesigner.AndroidDesignerSession.<Refresh>b__1f(Object )
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()


-------------------------

Installed Extensions
	AnkhSVN - Subversion Support for Visual Studio
	State	=	Enabled
	Version	=	2.4.11610.27

	WP7 Isolated Storage Explorer
	State	=	Enabled
	Version	=	1.0

	Microsoft Portable Library Tools
	State	=	Enabled
	Version	=	10.0.40328

	WiX Toolset
	State	=	Enabled
	Version	=	3.6

	NuGet Package Manager
	State	=	Enabled
	Version	=	2.0.30625.9003

	Mono for Android
	State	=	Enabled
	Version	=	4.2.6

	JSEnhancements
	State	=	Enabled
	Version	=	1.4.1

	Xaml Styler
	State	=	Enabled
	Version	=	1.5.7

	Visual Studio Zen Coding 2010
	State	=	Enabled
	Version	=	0.7

	JSLint.VS2010
	State	=	Enabled
	Version	=	1.3.11

	SQL Server Compact Toolbox
	State	=	Enabled
	Version	=	3.1.0.1

	XAML Regions
	State	=	Enabled
	Version	=	0.5

	Windows Phone Test Project
	State	=	Enabled
	Version	=	1.0

	CSSCop - FxCop for Stylesheets
	State	=	Enabled
	Version	=	1.2

	Image Optimizer
	State	=	Enabled
	Version	=	1.9

	Web Essentials
	State	=	Enabled
	Version	=	2.7

	Feature Builder Guidance
	State	=	Enabled
	Version	=	1.0

	Feature Builder Introduction
	State	=	Enabled
	Version	=	1.0

	Feature Builder Power Tool
	State	=	Enabled
	Version	=	1.0

	Feature Extension Runtime
	State	=	Enabled
	Version	=	1.0

	Feature Extension Ultimate Runtime
	State	=	Enabled
	Version	=	1.0

	JScript Brace Matching Extension
	State	=	Enabled
	Version	=	1.1

	JScript Editor Extensions
	State	=	Enabled
	Version	=	1.1.2

	JScript IntelliSense Para Extension
	State	=	Enabled
	Version	=	1.1.1

	JScript Outlining Extension
	State	=	Enabled
	Version	=	1.1.1

	JScript Word Highlighter Extension
	State	=	Enabled
	Version	=	1.1

	PowerCommands for Visual Studio 2010
	State	=	Enabled
	Version	=	1.0.2.3

	Productivity Power Tools
	State	=	Enabled
	Version	=	10.0.20626.18

	Project Linker
	State	=	Enabled
	Version	=	2.2.0.0

	Mindscape Visual Studio File Explorer
	State	=	Enabled
	Version	=	1.0.0.1

	Mindscape Web Workbench
	State	=	Enabled
	Version	=	3.2.419.21172

	Javascript Parser
	State	=	Enabled
	Version	=	3.5

	.NET Reflector Visual Studio Extension
	State	=	Enabled
	Version	=	7.6.1.824

	ISETools
	State	=	Enabled
	Version	=	1.0

	SlowCheetah - XML Transforms
	State	=	Enabled
	Version	=	2.4.1

	VSCommands for Visual Studio 2010
	State	=	Enabled
	Version	=	10.3.9.12

	Visual Nunit 2010
	State	=	Enabled
	Version	=	1.2.4

	Visual Assist X
	State	=	Enabled
	Version	=	10.6.1850.0



-------------------------

Environment Data
VisualStudio.Version	=	10.0
VisualStudio.Edition	=	Ultimate
VisualStudio.FullName	=	C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
VisualStudio.RegistryRoot	=	Software\Microsoft\VisualStudio\10.0
VisualStudio.LocaleId	=	1033
VisualStudio.DisplayMode	=	vsDisplayMDITabs
Time.UTC	=	02/10/2012 12:01:56
Time.Local	=	02/10/2012 13:01:56
OS.Architecture	=	AMD64
Environment.Version	=	4.0.30319.269
Environment.HasShutdownStarted	=	False
Environment.OSVersion.Platform	=	Win32NT
Environment.OSVersion	=	6.1.7601.65536
CurrentThread.Id	=	1
CurrentThread.Name	=	[null]
CurrentThread.ThreadState	=	Background
CurrentThread.IsBackground	=	True
CurrentThread.UICulture	=	English (United States)
CurrentThread.Culture	=	English (Ireland)
Process.PagedMemorySizeMB	=	713.63671875
Process.MaxWorkingSetMB	=	1.34765625
Process.NonpagedSystemMemorySizeMB	=	0.237991333007813
Process.PagedSystemMemorySizeMB	=	1.78002166748047
Process.PrivateMemorySizeMB	=	713.63671875
Process.VirtualMemorySizeMB	=	1510.27734375
Process.WorkingSetMB	=	788.0703125
Process.UpTime	=	01:39:48.1253083
Comment 4 André Ingar Sørensen 2012-10-11 07:40:05 UTC
Yup, this is happening after upgrade to 4.2.6.
Comment 5 proteas 2012-10-26 01:11:58 UTC
Confirming that the same behavior is also occuring 
while using VS-2012 64-bit and Mono for Android under Windows-8 Pro 64-bit.

Also encountered the same problem with Xamarin.AndroidDesigner crashing Visual Studio after a while.

I haven't found a solution yet.
Comment 6 George L. 2012-10-28 19:43:30 UTC
I have the same problem. It appears to me that the problem is strictly related to TableLayouts. I have other layouts without tables and they work fine. Any layout with a table will not open. The very same layout file in MonoDevelop will open and render properly.
Hope this helps to find a solution soon.
thanks
Comment 7 Andrew Way 2012-11-01 23:50:28 UTC
On behalf of : isaac.eckert@fanucrobotics.com
Visual Studio crashes when opening existing axml in designer.

Designer does not crash when opening new or empty layouts. 

-----------

Microsoft Visual Studio Professional 2012
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.5.50709
 
Installed Version: Professional
 
Team Explorer for Visual Studio 2012   04938-004-0031003-02544
Microsoft Team Explorer for Visual Studio 2012
 
Visual Basic 2012   04938-004-0031003-02544
Microsoft Visual Basic 2012
 
Visual C# 2012   04938-004-0031003-02544
Microsoft Visual C# 2012
 
Visual C++ 2012   04938-004-0031003-02544
Microsoft Visual C++ 2012
 
Visual F# 2012   04938-004-0031003-02544
Microsoft Visual F# 2012
 
Visual Studio 2012 Code Analysis Spell Checker   04938-004-0031003-02544
Microsoft® Visual Studio® 2012 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.
 
Mono for Android   4.2.7
Visual Studio plugin to enable development for Mono on Android.
 
NuGet Package Manager   2.0.30625.9003
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
 
PreEmptive Analytics Visualizer   1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
 
SQL Server Data Tools   11.1.20828.01
Microsoft SQL Server Data Tools
 
Web Developer Tools   1.0.30710.0
Microsoft Web Developer Tools contains the following components:
Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
Web Form Templates: Includes the default templates for Web Form Applications.
Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.
 
 
Here are my system settings (note I am running Windows 7 on a virtual machine on a Mac):
-------------------------------------------------------------------------------------------------
OS Name          Microsoft Windows 7 Professional
Version 6.1.7601 Service Pack 1 Build 7601
Other OS Description    Not Available
OS Manufacturer           Microsoft Corporation
System Name   354HQ12609
System Manufacturer     Parallels Software International Inc.
System Model   Parallels Virtual Platform
System Type     x64-based PC
Processor         Intel(R) Core(TM) i7-2675QM CPU @ 2.20GHz, 2200 Mhz, 2 Core(s), 2 Logical Processor(s)
BIOS Version/Date        Parallels Software International Inc. 7.0.15107.796624, 10/26/2007
SMBIOS Version           2.3
Windows Directory        C:\Windows
System Directory          C:\Windows\system32
Boot Device      \Device\HarddiskVolume3
Locale  United States
Hardware Abstraction Layer       Version = "6.1.7601.17514"
User Name        FRNA\eckertia
Time Zone         Eastern Daylight Time
Installed Physical Memory (RAM)           2.00 GB
Total Physical Memory  2.00 GB
Available Physical Memory        940 MB
Total Virtual Memory      4.00 GB
Available Virtual Memory           1.47 GB
Page File Space            2.00 GB
Page File          C:\pagefile.sys
Comment 8 Isaac.Eckert 2012-11-02 09:32:24 UTC
I believe the crash is causes by layouts that contain references to the TableLayout control.  However, my layout does reference a custom view, YellowBackgroundGadget, which derives from RelativeLayout and contains a header, web view, and references to 9-patch backgrounds.  

When I remove references to YellowBackgroundGadget the crash still occurs.  When I remove the TableLayout control also, the crash does not occur.

The source code for the layout and YellowBackgroundGadget control are below.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#cccccc"
    android:minWidth="25px"
    android:minHeight="25px">
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="*"
        android:id="@+id/tableLayout1">
        <TableRow
            android:id="@+id/tableRow2"
            android:layout_weight="0.333">
            <Android.iRConnect.YellowBackgroundGadget
                android:id="@+id/alertsGadget"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_column="0"
                android:layout_span="2"
                android:layout_marginLeft="4dp"
                android:layout_marginTop="4dp"
                android:layout_marginRight="4dp"
                android:layout_marginBottom="2dp" />
        </TableRow>
        <TableRow
            android:id="@+id/tableRow3"
            android:layout_weight="0.333">
            <Android.iRConnect.YellowBackgroundGadget
                android:id="@+id/gadget2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_column="0"
                android:layout_marginLeft="4dp"
                android:layout_marginTop="2dp"
                android:layout_marginRight="2dp"
                android:layout_marginBottom="2dp" />
            <Android.iRConnect.YellowBackgroundGadget
                android:id="@+id/gadget3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_column="1"
                android:layout_marginLeft="2dp"
                android:layout_marginTop="2dp"
                android:layout_marginRight="4dp"
                android:layout_marginBottom="2dp" />
        </TableRow>
        <TableRow
            android:id="@+id/tableRow4"
            android:layout_weight="0.333"
            android:minWidth="25px"
            android:minHeight="25px">
            <Android.iRConnect.YellowBackgroundGadget
                android:id="@+id/gadget4"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_column="0"
                android:layout_span="2"
                android:layout_marginLeft="4dp"
                android:layout_marginTop="2dp"
                android:layout_marginRight="4dp"
                android:layout_marginBottom="4dp" />
        </TableRow>
    </TableLayout>
</LinearLayout>



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Android.Webkit;

namespace Android.iRConnect
{

  public class YellowBackgroundGadget : RelativeLayout
  {
    private TextView _headerTextView;
    private FrameLayout _headerLayout;
    protected WebView _webView;

    public YellowBackgroundGadget(Context context, IAttributeSet attrs) :
      base (context, attrs) {
      Initialize();
    }

    public string HtmlContent { get; set; }

    private string _headerText;

    public string HeaderText {
      get {
        return _headerText;
      }
      set {
        if (_headerText != value) {
          _headerText = value;
          if (_headerTextView != null) {
            this.Post(() => {
              _headerTextView.Text = value;
            });
          }
        }
      }
    }

    private void Initialize() {

      //this.Orientation = Android.Widget.Orientation.Vertical;
           
      _webView = new WebView(this.Context);
      _headerLayout = new FrameLayout(this.Context) {
        Id = 1
      };

      this.InitializeGadgetView();
      
      RelativeLayout.LayoutParams headerLayout = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
      _headerLayout.LayoutParameters = headerLayout;
      
      this.AddView(_headerLayout);
      
      _headerTextView = new TextView(this.Context);
      _headerTextView.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent);
      _headerTextView.Text = this.HeaderText;
      _headerTextView.SetTextColor(new Android.Graphics.Color(0xE1, 0xE0, 0x10, 0xff));
      _headerTextView.SetTextSize(ComplexUnitType.Sp, 12);
      _headerTextView.Gravity = GravityFlags.Center;
      _headerTextView.SetTypeface(Android.Graphics.Typeface.DefaultBold, Android.Graphics.TypefaceStyle.Normal);
      
      _headerLayout.AddView(_headerTextView);
      _headerLayout.SetBackgroundDrawable(this.Resources.GetDrawable(Resource.Drawable.gadget_header_background));

      FrameLayout _contentContainer = new FrameLayout(this.Context);
      RelativeLayout.LayoutParams contentLayout = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent) {
        TopMargin = -5
      };
      contentLayout.AddRule(LayoutRules.Below, _headerLayout.Id);
      _contentContainer.LayoutParameters = contentLayout;
      _contentContainer.SetBackgroundDrawable(this.Resources.GetDrawable(Resource.Drawable.gadget_background));
      _contentContainer.SetPadding(2, 5, 2, 2);
      this.AddView(_contentContainer, 0);
      
      _webView.Settings.JavaScriptEnabled = true;
      _webView.SetBackgroundColor(new Android.Graphics.Color(0, 0, 0, 0));
      _webView.LayoutParameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FillParent, FrameLayout.LayoutParams.FillParent);

      _contentContainer.AddView(_webView);
    }

    public void Refresh() {
      
      string mime = "text/html";
      string encoding = "utf-8";

      StringBuilder html = new StringBuilder();

      html.Append("<html><head>");
      html.Append("<style type=\"text/css\">");
      
      html.AppendFormat("html,body {{ margin:0; padding:0; width:100%; height:100% }} \n" +
        "div.rcgadget_container {{ margin:0; padding:0; width:100%; height:100%; position:relative;}} \n" +
        "div.rcgadget_content {{ top:{0}px; right:{1}px; bottom:{2}px; left:{3}px; overflow:hidden; position:absolute; }} \n" +
        ".label {{ font-size: {5}px;text-wrap:none;overflow:hidden;white-space:nowrap;}} \n" +
        ".label.bold {{font-weight:bold}} \n" +
        ".label.alignleft {{text-align:left}} \n" +
        ".label.withellipsis {{ text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}} \n" +
        "td {{margin:0px; padding:{4}px 0px;}} \n" +
        "table {{border-spacing: 0;border-collapse:collapse;}} \n", this.Context.DpToPixel(5), this.Context.DpToPixel(5), this.Context.DpToPixel(5), this.Context.DpToPixel(5), 
                        this.Context.DpToPixel(1), this.Context.SpToPixel(8));
      
      html.Append("</style></head>");
      
      html.Append("<body style=\"font-family:sans-serif;margin:0;padding:0;\" ><div class=\"rcgadget_container\" ><div class=\"rcgadget_content\" >");

      this.RefreshContent();
      html.Append(this.HtmlContent);
      html.Append("</div></div>");
      html.Append("</body></html>");

      this.Post(() => {
        _webView.LoadDataWithBaseURL(null, html.ToString(), mime, encoding, null);
        _webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
      });
    }

    protected virtual void RefreshContent() {
      this.HtmlContent = "Hello Android!";
    }

    protected virtual void InitializeGadgetView() {
      //Not implemented here
    }
  }
}
Comment 9 Lluis Sanchez 2012-11-02 13:57:19 UTC
This designer issue was fixed in Mono for Android 4.2.8

*** This bug has been marked as a duplicate of bug 7149 ***