Compilation fail error

  • Thread starter Thread starter Boris
  • Start date Start date
B

Boris

Hi folks!

Look at the code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace LstView
{
/// <summary>
/// Summary description for Form1.
/// </summary>

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader ch1;
private System.Windows.Forms.ColumnHeader ch2;
private System.Windows.Forms.ColumnHeader ch3;

/// <summary>
/// Required designer variable.
/// </summary>

private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//

InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

InitListView();
}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>

private void InitializeComponent()

{

this.listView1 = new System.Windows.Forms.ListView();

this.ch1 = new System.Windows.Forms.ColumnHeader();

this.ch2 = new System.Windows.Forms.ColumnHeader();

this.ch3 = new System.Windows.Forms.ColumnHeader();

this.SuspendLayout();

//

// listView1

//

this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {

this.ch1,

this.ch2,

this.ch3});

this.listView1.HeaderStyle =
System.Windows.Forms.ColumnHeaderStyle.Nonclickable;

this.listView1.Location = new System.Drawing.Point(16, 24);

this.listView1.MultiSelect = false;

this.listView1.Name = "listView1";

this.listView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;

this.listView1.Size = new System.Drawing.Size(256, 224);

this.listView1.TabIndex = 0;

this.listView1.View = System.Windows.Forms.View.Details;

this.listView1.SelectedIndexChanged += new
System.EventHandler(this.listView1_SelectedIndexChanged);

//

// ch1

//

this.ch1.Text = "ch1";

//

// ch2

//

this.ch2.Text = "ch2";

//

// ch3

//

this.ch3.Text = "ch3";

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 273);

this.Controls.Add(this.listView1);

this.Name = "Form1";

this.Text = "Form1";

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void InitListView()
{
string [] item1=new string[3];
item1[0]="start";
item1[1]="end";
item1[2]="free";
ListViewItem lvi = new ListViewItem(item1);
listView1.Items.Add(lvi);
}

private void listView1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
foreach(ListViewItem lvi in listView1.ListViewItemCollection)
{
}
}
}
}



I know that listView1 have Items property of type ListViewItemCollection,
but if I by mistake wrote ListViewItemCollection why compiler should stuck?
 
Hi Boris,


ListViewItemCollection is a class declared inside ListView, it's not a
property of ListView, if you want to get the items in the ListView you have
to use ListView.Items that is an instance of ListViewItemCollection.
Your for loop will looks like:
foreach(ListViewItem lvi in listView1.Items)
{
}

Hope this help,
 
Yes, I agree with You completely. But am I wrong by asking from compiler to
be more precice and not to fail with internal compiler error. Try to compile
code that I passed.
:)
 
Yes, it fails with "internal compiler error". Looks like it is problem
inside the compiler. At least it gives you the nearest point where to look
for an error.
 
Hi,

Indeed it's a compiler bug, when I try to compile the code it gives me
"Internal Compiler Error: stage 'COMPILE' among others.

I think that MS should get a report of this.

Also the IDE gets screw up, from that moment all the files in the projects
lost the colors for the reserved words and the autocomplete does not work,
it's only after the delete the code and recompile that all return to nornal.


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
 
Actually, I didn't have problems with the IDE or at least I didn't spoted
any.
 
Hi,

Mine got completed trashed.
I just added a new form to an existen windnows app, ( I removed the Main
method from the code listed ).



Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
 
Can somebody please provide the version of the compiler you're using and any
service packs you've installed? I'm having trouble reproducing the internal
compiler error (I'm using 7.0).
 
Thank you for posting this information. An internal compiler error
basically means the compiler crashed (AV, stack overflow, or something
worse) and tried to clean up after itself. Usually the IDE is stable enough
to save your work and exit, and that is exactly what I would recommend you
do whenever you get an internal compiler error. And please continue to
report them to MS.
 
Back
Top