In my VsShell project, I have a DesignerWindowPane, which handles the IComponentChangeService.OnCompontentChanging() event.
According to the documentation on the MSDN, I'm supposed to throw an exception if I want to stop the Change from occuring.
http://msdn.microsoft.com/en-ca/library/system.componentmodel.design.componentchangingeventargs.aspx When this gets called (just like the ComponentAdding/Removing) I check if Source Control allows edits, which prompts the user, and if they cancel (or someone else has the file checked out etc) I throw an exception. This exception works great for OnComponentAdding/Removing and for 99% of the ComponentChanging scenarios it works. If I modify a property or drag a control that's on the form, it works correctly. If I resize a control via the property box (size property), it cancels the change correctly.
But, if I try to resize the form using a control's resize container it throws an exception and crashes the Shell. The stack is indicating this isn't a problem in my code (entire exception below). Does anyone have any suggestions, or should I raise the issue for MS to investigate?
The Exception I'm throwing in the ComponentChanging handler is InvalidOperationException("My text")
Using:
VsShell 1.1
VS 2008 SP1
Windows XP Prof
Exception:
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="System.Design"
StackTrace:
at System.Windows.Forms.Design.Behavior.BehaviorService.AdornerWindow.MouseHook.MouseHookProc(Int32 nCode, IntPtr wparam, IntPtr lparam)
InnerException: