Bug 549003

Summary: NullReferenceException caused by refactor rename of event handler
Product: [Mono] MonoDevelop Reporter: Bryan Zimmerman <codeabit>
Component: generalAssignee: MD Bugs <monodevelop-bugs>
Status: RESOLVED DUPLICATE QA Contact: MD Bugs <monodevelop-bugs>
Severity: Normal    
Priority: P5 - None    
Version: 2.0   
Target Milestone: ---   
Hardware: x86   
OS: Linux   
Whiteboard:
Found By: Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Bryan Zimmerman 2009-10-22 04:21:54 UTC
Description of Problem:

MonoDevelop NullReferenceException while trying to refactor rename and event handler

Steps to reproduce the problem:
I receive a repeatable MonoDevelop unhandled exeption (see stack below) by:
1. right clicking on the event handler "handleItHappened" in the following code
2. selecting method rename from the context menu(s) for the method
3. Give the method a new name
4. Click OK button
  
Actual Results:

System.NullReferenceException: Object reference not set to an instance of an object
  at MonoDevelop.Core.Gui.ResourceService.GetIcon (System.String name, IconSize size) [0x00000] 
  at MonoDevelop.Core.Gui.ResourceService.GetBitmap (System.String name, IconSize size) [0x00000] 
  at MonoDevelop.Ide.Gui.BackgroundProgressMonitor+<BackgroundProgressMonitor>c__AnonStorey40.<>m__38 (System.Object , System.EventArgs ) [0x00000] 
  at Gtk.Application+InvokeCB.Invoke () [0x00000] 
  at GLib.Timeout+TimeoutProxy.Handler () [0x00000] 

Expected Results:

Method renames without error or exception

How often does this happen? 

happens every time

Additional Information:

Here's the test code I was running when it happened...

using System;

namespace test
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			var msg = "Hello";
			var a = new A();
			var b = new B();
			b.GetIt();
			msg = a.GetIt();
			msg = Extensions.GetIt(new B());
			a.ItHappened += handleItHappened;
			Console.WriteLine(msg);
		}

		static void handleItHappened(object sender, EventArgs e)
		{
			
		}
	}
	
	public static class Extensions
	{
		public static string GetIt(this A obj)
		{
			return "It";	
		}
	}
	
	public class A
	{
		public string GetIts()
		{
			return "Not it";	
		}
		
		public event EventHandler ItHappened;
	}
	
	public class B : A
	{
		
	}
}
Comment 1 Michael Hutchinson 2009-10-22 15:25:33 UTC
Duplicate, and the ResourceService was rewritten (as the ImageService) for 2.2.  Please reopen if it still happens with 2.2.

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