the home row

the home row | February 2010

Unity - GetRootException extension method

by Rob 17. February 2010 00:27

One of the complaints I hear regularly is that debugging container resolution exceptions can be difficult. Well, unknown to many Unity has a handy extension method that helps you with this very problem. GetRootException can be found in the  Microsoft.Practices.Composite.ExceptionExtensions class. The method loops through inner exceptions to find the likely place that the most relevant exception took place. Below you can see three constructors for classes that are composed together. All should resolve except that the ApplicationCommands class takes an interface IInterfaceWeForgetToAdd that doesn’t have an implementation added to the container.

public Shell(IShellViewModel shellViewModel)
public ShellViewModel(IApplicationCommands commands, IEnumerable<IMenuItemViewModel> menuItems)
public ApplicationCommands(IRegionManager regionManager, IInterfaceWeForgetToAdd iwfta)

Below is a screen shot of where you’d need to dig around to find the relevant exception message that tells you what the problem is when resolving the Shell.

image

 

 

Or alternatively you can call the GetRootException extension method on the caught exception and then look at the message to get the following useful pointer to where things went wrong:

"The current type, Contracts.Services.IInterfaceWeForget, is an interface and cannot be constructed. Are you missing a type mapping?"

Tags:

Visual Studio 2010 – Adding zoom keyboard shortcuts

by Rob 4. February 2010 23:34

Visual Studio 2010 has now incorporated the ability to zoom in and zoom out of the editor. This feature is activated by holding down the control key and using the mouse wheel to zoom in and out. The image below shows the editor zoomed in to 345%, which is displayed in the bottom left corner.

Editor zoomed in to 345%

If you're a keyboarder  like me then you'll be wanting to know how this can be achieved without using the mouse. The default settings don't support this, but you can easily map the correct commands to keyboard shortcuts. The commands you’ll need to map are:

view.zoomin

view.zoomout

These can be set through Tools > Options > Environment > Keyboard

Options to set zoomin keyboard shortcut

Tags: ,

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About the author

Rob Henry - .Net Developer and Keyboard Junkie

Page List