[Gtk-sharp-list] where is the problem in this code?

Jaime Anguiano Olarra jaime@gnome.org
26 Feb 2003 21:40:40 +0100


Hi!

I am using this code to write files and I can't understand why I get
System.NullReferenceException: A null value was found where an object
instance was required

when I use the following method:

	TextIter start_iter, iter;
	StreamWriter writer = new StreamWriter (file);
	string text;
								
	iter = textbuffer.StartIter; // the error seems to be here
	start_iter = iter;
	while (iter.ForwardLine ())
	{
		text = textview1.Buffer.GetText (start_iter, iter, false);
		writer.Write (text);
		start_iter = iter;
	}
	text = textview1.Buffer.GetText (start_iter, iter, false);
	writer.Write (text);  
	writer.Close ();
	writer = null;

textbuffer is a TextBuffer created as textbuffer = textview.Buffer;
where textview is created as textview = (Gtk.TextView) ui["textview1"];

Any ideas, I am stopped with that silly thing.

Thanks in advance,

Jaime.

-- 
http://www.go-mono.org -- The Mono Project, .net + freedom.