Creating a new folder with resharper generate option - c#

With Resharper generate option (Alt+Insert), you can create a new folder from the solution explorer in Visual Studio.
I always used this feature for some years.
I click on an existing folder or at the root of a project and press 'Alt+Insert' and the last option is 'New Folder'.
Today, one of my co-worker who have seen this feature on my computer just tried to reproduce the behavior on his computer but without success; the 'New folder' option is not visible.
Is there any option in Resharper to be able to see this option in the generate popup?

Most likely keyboard shortcut got messed up. Go to Tools -> Options -> Environment -> Keyboard.
Search for Resharper_Generate command and assign your preferred shortcut key (alt + insert). That should do the trick.

The "New Folder" option only appears when the focus is on a folder or a project. If you display the menu on a file, it doesn't appear.

Related

Visual Studio 2017 keep file open by default

I have an annoying problem with Visual Studio 2017.
Whenever, I open a file using Ctrl+Click navigation, the the file gets opened in purple tab preview mode (for a lack of better term).
Please note: I'm not asking about Visual Studio Code, I'm asking about VS 2017. I know how to change these setting in VSCode. After googling multiple times for VS2017, I finally gave up. Maybe I didn't phrase the question correctly.
Example shown below.
After I click on the "Keep Open" option, the file gets added to the open set of tabs.
I would prefer to have this behavior by default.
Also, it it possible to add this tab to the right of all other open tabs? Currently, it adds itself to the beginning. I prefer to append new tabs to the right/rear.
You can uncheck the Allow new files to be opened in the preview tab option to keep files open:
And there is the Insert new tabs to the right of existing tabs option nearby to add this tab to the right of all other open tabs.

Hide Class-View in Solution Explorer

Is there a way to hide the classes-inside-a-file in solution explorer?
It adds to the "noise" there. The drop-down triangles are quite confusing - I want to immediately see what files are hidden (in solution explorer).
Instructions for Visual Studio 2017:
Close Visual Studio 2017
Open Registry Editor (regedit), select HKEY_USERS
File → Load Hive → %localappdata%\Microsoft\VisualStudio\15.0_<id>\privateregistry.bin where <id> is some hexadecimal gibberish. Set Key Name to the one you like e.g. vs2017
Go to HKEY_USERS\vs2017\Software\Microsoft\VisualStudio\15.0_<id>
Create new key UseSolutionNavigatorGraphProvider of DWORD (32-bit) type, value 0
Select HKEY_USERS\vs2017, File → Unload Hive
For VS2017 use Disable Solution Explorer's Dynamic Nodes extension github
or in VS Command prompt:
vsregedit set "%VSINSTALLDIR%/" HKCU "" UseSolutionNavigatorGraphProvider dword 0
Use registry editor to set UseSolutionNavigatorGraphProvider value in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0 to 0. Or save the following lines into a file called "patchsolutionexplorer.reg" or something like this and import it into the registry:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0]
"UseSolutionNavigatorGraphProvider"=dword:00000000
For VS2019 it's the same registry hack
Computer\HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\16.0_<id>
Add new DWORD UseSolutionNavigatorGraphProvider set to 0
info from this link
Still some people never use the Solution Explorer to navigate the code
symbols and methods. In this case expansion arrows on code files only
create distraction in the Solution Explorer window. There is no option
to control the availability of file expansion, but there is the
UseSolutionNavigatorGraphProvider dword registry value (discovered by
Julien Lebosquain) that you can set to 0 to disable class view in
Solution Explorer. The registry key for this value is
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0 for Visual
Studio 2012 and HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0
for Visual Studio 2013 correspondingly:
it's makes sense for you?
In VS2017 (and pretty sure in VS2015 also), click on the little triangle to the right of the search box in Solution Explorer. In the window that pops up, uncheck 'Search within file contents'. That will only show files in the filtered results.
Bit late into the game.
This extension hides dynamic nodes.
Disable Solution Explorer's Dynamic Nodes
If you install the extension VSCommands, you have a setting to disable this.
http://vscommands.squaredinfinity.com/
Go to Tools -> Options -> VSCommands 12 and press the "Open Configuration" button.
Now the configuration screen of VSCommands will open. Go to "Solution Explorer" under "IDE Enhancements". Now check the checkbox "Disable Graph provider" and restart Visual Studio.
Now the classes inside a file should not be visible anymore in the Solution Explorer.

"A project with an Output type of Class Library cannot be started directly"

I downloaded a C# project and I wish to debug the project to see how an algorithm implementation works.
The project has come in a Folder, inside this folder there are -
.sln file and
a folder which has source files and a .csproj file.
I installed Visual Studio and opened the .sln file present in the main folder. I built the project successfully, but when I try to debug the project I get this message:
A project with an Output type of Class Library cannot be started directly In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.
The strange part is that I don't see a main function anywhere.
What should I do to get round this hiccup?
The project you have downloaded compiles into a dll assembly and provide a set of classes with implemented functionality.
You should add to your solution a new project with Output Type of either Console Application or Windows Application (VS Add Project wizard will offer you different templates of Projects).
In the newly added project, you can implement logic to test your Class Library.
Output type of the project you can find and change by the following steps:
Right click on project in Solution Explorer -> Properties.
In opened tab with properties select Application and there will be ComboBox marked with Output Type label.
Just right click on the Project Solution
A window pops up.
Expand the common Properties.
Select Start Up Project
In there on right hand side Select radio button with Single Startup Project
Select your Project in there and apply.
That's it. Now save and build your project. Run the project to see the output.
This was the solution that worked for me since I couldn't find 'Common Properties' option.
Select your topmost level project in Solution Explorer.
Go to Project, and in contextual menu Set as StartUp Project.
See also: A project with an Output type of Class Library cannot be started directly
Just needs to go:
Solution Explorer-->Go to Properties --->change(Single Startup project) from.dll to .web
Then try to debug it.
Surely your problem will be solved.
The strange part is that I don't see a main function anywhere.
That is exactly your problem. The project merely creates a DLL. It has no executable to run.
You will need to add a second project, which is an executable which references the other project, and calls something in it.
1) Right Click on **Solution Explorer**
2) Go to the **Properties**
3) Expand **Common Properties**
4) Select **Start Up Project**
5) click the radio button (**Single Start_up Project**)
6) select your Project name
7) Then Debug Your project
Right Click on "Solution Explorer" -> "Properties"
Expand "Common Properties"
Select "Start Up Project"
click the radio button "Single Start_up Project"
select your Project name from the drop down list.
If still not working after the above steps, then try this.
Expand solutions explorer.
Right click on project name -> "Properties"
Go to "Application" tab
Select "Output type"
From the drop down list select the appropriate type according to your application.
"Windows application" or
"Console application"
Then save (ctrl + S)
Try debugging (F5)
You'll need some kind of app (Console Apps are my favorite for debugging, but a WinForm will do) which uses your Class Library. Just add a new project (in the same solution) of a Console Application or Windows Forms Application, and add a reference to your current project. Once you've done that, make any calls you need, set your break points, and go to town.
I had a similar issue when trying to use the Experimental Instance of Visual Studio 2013. This was for a vsix project (Creating Snippets).
Solution was:
Right Click Project in Solution Explorer > Properties > Debug
Setting the Start Action to "Start external program" and using the following path:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
This option was set to "Start project" which won't work for the application output type Class Library, which caused that same error.
Note: Yours may differ depending on how you installed VS.
Error solutions is that you have already open your project but by mistake you have selected another class library .. that's reason this error is showing ... so what u need to do you u just select u r project then right click on u r project
after right click u can see the list box and select the "Set as start up project " option .
Accepted answer works if your solution has a project that compiles to an exe. If your solution does not have any projects that compile to an exe, then you have to use 'Start external program'.
VS2019 instructions:
right click -> properties on the main solution
debug, start external program, and add command line arguments
VS2022 instructions:
right click -> properties on the main solution
scroll down to Debug
Debug > General > Open debug launch profiles UI
left click the 'new' icon in the top left, select 'executable'
fill it out as per VS2019 (pick the exe and add command line arguments)
when clicking the start button, first select the profile you made
Suppose you have multiple project in the solution. Select the project that you want to view in browser and select 'Set as StartUp Project'. In your multiple project soln which was the main, the visual studio was unable to identify. this was the main problem.
You can right click the Class Library project and from the drop-down choose Initialize Interactive C# which will load your project context and you can work it in the interactive session.
In my case, the cause was that one of my projects in the solution wasn't loaded. The reason it couldn't load properly was that the file path length of one of the files was too long. Upon deleting this long file, I could reload the project, and build the solution.
If the question involves an Azure project, make sure you have the "Azure development" tool set installed, or when you go to run a solution you may get this same error.
Tools > Get Tools and Features... > Tick the box next to Azure development > Click install
None of the answers provided above helped me resolve this error, this is what resolved the issue for me.
Right click on the solution and select "Properties", which is in my case "Sintctech.Data".
Select the section called "Application".
Check what you have selected as your output type. If it is "Windows Application", change it to "Console Appication".
Rebuild and the problem should be fixed.

Changing the Default Installation Path in Windows Application

I want to Change default installation path which is Program Files in windows application When Creating setup. I tried but i couldn't do that please tell me solution.
Right click on your setup project
root in Solution Explorer and choose "View -> File System"
Click on (select)
"Application Folder" in the window
which opened.
If you look in the
"Properties Pane" in Visual Studio there is an entry
called "DefaultLocation". Change this
to point it somewhere besides
"Program Files".
Default value for location is [ProgramFilesFolder][Manufacturer]\[ProductName]. These are placeholders variables which are looked up when you compile the setup project. [ProgramFilesFolder] is the one which will point to "Program Files" in an English version of Windows.
In a Visual Studio Setup project, you control the default install path by setting the DefaultLocation property of the Application Folder folder, within the File System Editor.
This, in turn, as you've found, defaults to [ProgramFilesFolder][Manufacturer]\\[ProductName]. You can either replace this property entirely or you can modify these properties.
Ex: D:\\[Manufacturer]\\[ProductName]
Here it is
Right click on your setup project root in Solution Explorer and choose "View -> File System"
Click on (select) "Application Folder" in the window which opened.
If you look in the "Properties Pane" in Visual Studio there is an entry called "DefaultLocation". Change this to point it somewhere besides "Program Files".
The other solutions don't work for VS 2012 and above. Please follow these steps:
Expand Setup and Deployment Project.
Select Project Assistant, bottom you will find "Installation Interview", click on "Installation Interview".
You can see the Installation Dialogs, select "Yes" for option "Do you want your users to be able to modify the installation location of your application?"

Ctrl+R, Ctrl+R command not working

I'm attempting to use the Ctrl+R, Ctrl+R command within Visual Studio 2008 to rename a variable. I get an error message at the bottom saying that
"The key combination (Ctrl+R, Ctrl+R) is bound to command (&Rename...) which is not currently available."
I am not running it or anything I can think of which might prohibit modifications of the file and the F2 command allows a rename to happen. Anyone know how to fix this?
EDIT: I do have Resharper installed but was previously able to do this with the same setup, I recently migrated computers.
I was able to fix this by doing the following:
Go to Resharper → Options menu commmand
Select Environment → Keyboard & Menus
Select the Visual Studio option under Keyboard Shortcuts
Click Apply Scheme and Save
This will cause Ctrl+R, Ctrl+R to do a rename. (Select ReSharper options in the dialog box that pops up then.)
However, it made F2 no longer able to preform a rename. I was able to fix that by doing the following:
Go to ReSharper → Options menu command
Select Environment → General
Select the ReSharper 2.x or IntelliJ IDEA under Restore ReSharper keyboard shortcuts
Click Apply or OK
This allows both F2 and Ctrl+R, Ctrl+R commands to work for renaming a variable.
This seems to be specific to ReSharper being installed with Visual Studio, I don't know what the solution would be to fix this if ReSharper weren't installed.
For Resharper 6
You should:
Select menu "Resharper" - "Options..."
Select "Visual Studio Integration"
Choose "Visual Studio" in both places
Click "Apply Scheme"
It will either works or you will have a selection to do (Visual Studio or Resharper), if it is so, then choose Resharper.
resharper has multiple default shortcut bindings that is chosen the first time you start visual studio after instalation. My guess is you picked a different one this time.
In my case the problem was solved by clearing the ReSharper cache. This can be done in the options menu under Environment > General here:
This happened to me once. I had to reinstall Resharper (repair from Add/Remove programs probably) to get it to work. But that was with VS2005 though.
Using version 8 of ReSharper in Visual Studio 2013, I had to
Go to the RESHARPER menu -> Options
Expand Environment
Select Keyboard & Menus
Choose Visual Studio as the ReSharper keyboard scheme
Click Apply Scheme...Save & close dialog box.
The next time I executed a keyboard shortcut it prompted me to choose which keyboard shortcut I wanted to use.
Nothing has worked for me until I have tried upgrading my Resharper! :O
I'm guessing very few people will be in my situation but FWIW I was in this situation too where Refactor.Rename (Ctrl+R,Ctrl+R) was NOT working in Visual Studio 2019/Win 10, after reboots/restarts plus I did not have Resharper installed. In my case Refactor.Rename wasn't working because my project was in FOLDER mode not SOLUTION mode (OMFG). Soon as I used the solution tool to "Switch Views" and went into SOLUTION mode Refactor.Rename started working again. In hindsight this makes sense of course but some kind of error message/warning would have been nice to help me realize what the issue was!
For me, the issue was I hadn't started the Resharper evaluation which wasn't obvious because all of the Resharper extension options were accessible, but the clue was under:
Extensions -> Resharper -> Why Resharper Is Disabled.
Click "Start Evaluation" (in the same location as "Pause Evaluation" in the screenprint)
I expected the evaluation to start when I clicked "OK", but clearly it doesn't.
You get this behaviour in Visual Studio (without R# installed) if the editor window does not have focus when you issue the shortcut. I've just tried it with R# installed and it does the same thing.
Give the editor focus (ie. by clicking in it) and try again.
This is usually the shortcut used by Resharper. Is there any chance Resharper is not running?
Alternatively, you can change the name, hit Ctrl+. and then use Rename.
For DevExpress:
Open the Options screen (Ctrl+Alt+Shift+O)
Go to Core → Features
Set Default to Visual Studio shortcuts
For me, this problem was caused by me not clicking 'Accept" on the terms and conditions page, but closing it. I did not realize it was the terms and conditions, and thought it was just a notice, or a 'readme' being displayed.
All the answers above are well and good but this error also comes up in one more instance.
You start debugging your test script written for the project , the project stops at breakpoint .
If at this point , you try any operation on code , you will get the error similar to :
"The key combination (Ctrl+R, Ctrl+R) is bound to command (&Rename...) which is not currently available."
Restart Visual Studio.
Worked for me.
None of the above worked for me. I had to reset my resharper settings in the end.
Go to Resharper -> Manage Options
Click the "Reset All Settings" button
In my case (Visual Studio 2022 17.4.0 with Resharper 2022.2.2), I had to
disable Resharper
restart Visual Studio to make the change effective
enable Resharper
restart Visual Studio to make the change effective

Categories