Shortcut keys not working (Visual Studio 2010 with

2019-06-15 08:43发布

问题:

None of these shortcut keys appear to be working for me in VS 2010 with ASP.NET MVC 3 RC1.

I particularly would like to use CTRL + M, CTRL + G to "Go To Controller" but I keep receiving the error:

The key combination (CTRL+M, CTRL+G) is bound to command (Go To Controller) which is not currently available.

Thrown by the VS IDE. I have tried this obviously within an ASPX view file in Source code mode, but no luck. I receive the same error for all shortcuts tried.

PS: I am running ReSharper 5; could this be interfering?

回答1:

The shortcut keys in ASP.NET MVC 3 unfortunately conflict with the shortcuts from ASP.NET MVC 2. This means that when both products are installed (or, at least, their VS add-ins) the shortcuts won't work properly.

One workaround is to uninstall the versions of ASP.NET MVC that you are not using. You can uninstall the "tooling" components from Add/Remove Programs in the Windows Control Panel.



回答2:

The specific example you give (Go To Controller) is listed on the RC Known Issues list:

When you are editing a Razor view (.cshtml file), the Go To Controller menu item in Visual Studio will not be available, and there are no code snippets.

They don't mention the other keyboard shortcuts, but I assume they will be added back in when this issue is addressed.

Note: there is another item listed about Intellisense and Resharper, so you may want to take a look at the rest of the list.



回答3:

I had a similar issue just now, when my keys simply stopped working. I would press Ctrl+R R, for instance ("rename"), and would get the "..not currently available" message. Doing the same from the ReSharper menu however, would work fine.

I still have no idea what caused the conflict, but this solved it in any case:

  • Select Toos --> Options, and ReSharper on the left.
  • Click the Options button to open the ReSharper settings.
  • Now, under "Visual Studio Integration", make sure "Visual Studio" is selected under Keyboard Shortcuts (or whichever sheme you want)
  • Click Save (Note: you might have to click OK in the VS Options window first, even though it is hidden behind the R# winodow)
  • Now try using a ReSharper command again, and it should either work directly, or prompt you for a desired scheme to apply, as it did the first time you started using R#.