'Value does not fall within the expected range' error while adding toolbar to toolwindowDec 24, 2015 | Utkarsh Shigihalli VisualStudio Extensions Exception
Hello, this is going to be a small post. In one of my Visual Studio extension, I was trying to add a toolbar to the toolwindow. Everything compiled just fine and all seemed perfect. However, as soon as I tried to open the toolwindow (with toolbar) I was getting “Value does not fall within the expected range” error.
Obviously, error did not give me much details on what caused the error. Break on CLR exceptions setting lead me to this line.
1 ToolWindowPane window = this.package.FindToolWindow(typeof(MyToolWindow), 0, true);
So, Assuming an issue with my declarions of toolwindow, I verified GUID’s used, other declarations made in my VSCT file. All looked correct but still the same error.
After numerous debug sessions, found out that Visual Studio throws this error when the toolbar you are adding does not have any command added to it. That is, whenever you add a toolbar to the toolwindow, make sure you add at least one button (command) to it.
So adding a
Button element resolved the issue for me.