Where does Visual Studio save code blocks that are dragged on the Toolbox - visual-studio

You can drag and drop code blocks from the Codeeditor to the Toolbox of VisualStudio, but where does Visual Studio save those code blocks.
Are they globally available (for other projects) or only available in the solution/project they are dragged?

Any code blocks that you drag to the Toolbox are stored in your Visual Studio settings file. The default path to that file is under your "My Documents" folder:
..\My Documents\Visual Studio 2010\Settings\CurrentSettings.vssettings
but of course, the exact location can be specified from the Options dialog in Visual Studio.
They are globally available for all projects in the applicable language. For example, if you create a code snippet in a C# project, it will be available for any C# projects that you create. However, it will not be available in a VB.NET project.
Also note that you can rename the individual snippets by right-clicking on them in the Toolbox, and selecting "Rename Item" from the context menu.
But there is a better and much more powerful way to manage code snippets rather than dragging them to your Toolbox. See this article on Sara Ford's blog (a great resource for tips and tricks relating to VS).

Related

Visual Studio 2010 Toolbox Is Empty

My toolbox is empty.
Obviously, I'm not the first. I read this question and this other question, but that didn't help.
I click here...
I get this window...
With instructions that say: "...Drag an item onto this text, to add it to the toolbox..."
Sounds good; from where do I get such items to drag?
The toolbox is empty because there is no project loaded.
The toolbox is populated with tools/controls according to the type of the current project. The controls are different for MFC than they are for ASP.NET, for example. If you haven't loaded any project, Visual Studio can't populate the toolbox.
Either open an existing project, or go to File -> New Project to create a new one.
Have you tried right-clicking on it and selecting the "Reset Toolbox" option? You can also try to manually add specific tools to it by using the "Choose Items..." option.
A common suggest is also to go into the Visual Studio 2010 Directory and delete all of the .tbd files within the following directory (Related) :
C:\Documents and Settings\Local Settings\Application Data\Microsoft\VisualStudio\10.0"
Although if neither of these options work, you will really want to consider possibly reinstalling / repairing Visual Studio.
Is your project running? I noticed that my toolbox is empty when I am debugging the project. Try stopping debugging.

How to add action to Visual Studio Solution Explorer?

Please let me know how to add an action into the context-menu of "Solution Explorer" in Visual Studio?
I'd like to add my action into the context-menu of files listed in this explorer (see a screenshot for example), and then be able to launch my application (EXE file) that can get the filename (including its path) as an argument.
I currently use VS2008, however please let me know if that should be different with VS2010 and VS2012.
THANK YOU
Write your own visual studio Add-In take a look at that link this is good place to start. but its not easy...
You're going to have to write a Visual Studio Add-In.
Take a look at the code for the Xsd2Code addin on codeplex. Specifically the Connect class. This addin does something similar to what you want... it adds a context menu option that's available when you right-click on project items (in this case, only enabled for .xsd files).
Also, check out the Solution Explorer Context Menu sample within the Visual Studio 2005 Automation Samples download.

Visual Studio do not add my component (from a DLL) to the toolbox even if I reference it

As stated in the title, I copied my DLL in Visual Studio project, set it to "content" and "copy always". Added a reference to this DLL and set it to "copy locally".
I successfully managed to instance my component to a form through code but it doesn't appear in the toolbox, really boring.
How can I solve this issue?
If I link directly the DLL project to this project it works, but now I'm treating the DLL as "external" so it's not part of the same solution of the DLL project.
I had this problem with #AndrewFinnell's solution:
There are no components in 'c:....\XXXX.dll' that can be placed on the toolbox.
So I solved with drag and drop:
open Windows explorer and navigate to the DLL
drag the DLL and drop it on Visual Studio in the Toolbox, exactly where you want your components to appear.
I also realized that some components may have compatibility issues with certain .NET Framework versions. For instance A Professional Calendar/Agenda View That You Will Use seems not to work with .NET 4.5, while it does with .NET 4.
Right-click in the toolbox.
Click "Choose Items..."
Click "Browse..."
Navigate to your DLL and click Open
Then click "Ok"
Your components should then show up
The way I found to make this working is:
Add the dll, reference it
Compile the project
Save the solution and restart visual studio
And then controls show up in toolbox (not always working, I think is a sort of visual studio bug)
Like said above,
I reference the DLL in the client project by: in Solution Explorer right click > Add Reference, at this time the custom control doesn't appear in the Toolbox.
I save it and close the client project.
I restart Visual Studio 2012 and reopen the client project. Now the custom control is in the Toolbox.
I reopen the custom control project, make some modifications and compile.
And the most important, all changes that I made in the DLL project automatically were updated in the client project without need to redo "Add Reference".
Here is what I did.
After install the net 3.5 chart download from MSDN link, I manually copied the 3.5 chart dlls to my project and refer to them. Then, from the "choose item" of toolbox, browse to the dlls and add them into toolbox. Make sure the checkbox is checked for the "chart" in the "choose item" popup.
After these, the "chart" item in the toolbox should be available and enabled for .NET 3.5 project.
NOTE
(I am using Visual Studio 2010. I think my solution should work for 2012.)
I was having this same issue. I am working in Visual Studio 2010.
My user control library is written in C# and my project I'am importing it into is in Visual Basic.
If I had the C# project in my solution, the custom user controls would show up automatically. But if I only referenced the DLL it would not load the custom user controls from the referenced library into the "Toolbox".
The above post that mentions finding the file in explorer and dragging and dropping it into the toolbox solved the problem. This is a very strange way of behaving. VB user control libraries don't require this step.
This has been an issue I have had sitting on the burner for the last 2 years.
I would up-vote the previous answer but I don't have enough rep yet.
This post could use some better tags, cause it was buried on most of my google searches.
So
Reference the user control library
Drop the DLL file into the tool box.
One question I have in regards to this is: what happens if you change the project reference to the DLL (because it moved) and not attempt to update the toolbox reference (by removing the control from the toolbox and dragging and dropping the DLL from the new location)?
I tried following the other answers (thanks to all of you!), but I got this problem and I'll let you all know how I solved it and show my custom tools in toolbar (in VS 2017).
Place the .ddl file in any Library Solution
Then I add that .ddl as reference to my needed project
Build the project and restart the Visual Studio
Then, when I look into toolbox, my custom toolbox name appears in
toolbar, when I expand that I got below message
There are no Usable controls in this group. Drag an item onto this
text to add in to toolbok
I dragged the .dll and dropped under that text and then all my custom tools appeared in my toolbox.
And add lib. to folder in your solution example solutionfolder/bin/debug and then add reference to object from this folder, finally rebuild, quit, come back, drag and drop dll from this solutionfolder/.../../ and it will probably appear.

How to jump to a file in the Source Control Explorer in Visual Studio

I love the Solution Explorer > Right-click > "Open Containing Folder" feature of the PowerCommands extension for Visual Studio 2010. I want the equivalent of a "Jump to location in Source Control Explorer" feature. How can I find out the location in TFS of a given open file, or a file in the solution explorer (or a file in the solution navigator in you have the Productivity Power Tools extension)?
The best answer would be a couple of mouse clicks and no keyboard. Next best answer would be a hotkey mapping.
The only solution that I have found so far is to use the Productivity Power Tools extension which has the feature "Find in Source Control". A file in the results list can be right-clicked to "Open folder in Source Control Explorer". The drawbacks to this solution is that is takes many clicks, and the search results can match more than one file if files exist with the same name in different folders.
There is a stand-alone extension that you can download, called Locate in TFS, within Visual Studio.
"Locate in TFS" on TFS Gallery
"Locate in TFS" on GitHub
This also works on files that you "Exclude from source control", as many developers do with the web.config files.
psulek's post, above, mentions this as part of VSCommands, but I prefer the stand-alone extension.
Try Visual Studio extension VSCommands for Visual Studio 2012. It has feature called Locate in TFS. This will add new button to Solution Explorer Locate in TFS which opens active selected file/folder in TFS Source Control Explorer.
Feature request has been raised with Visual Studio team. Read here
I know it's probably too late. See TfsExt extension for vs2010
I'm not sure if it's possible, but it's a good suggestion.
These two examples show how to use the Visual Studio Extensibility APIs to access the TFS Source Control Explorer APIs.
http://blogs.msdn.com/b/edhintz/archive/2006/02/03/524312.aspx
http://blogs.msdn.com/b/bharry/archive/2008/07/09/working-on-tfs-sdk-improvements.aspx
For Visual Studio 2013 try lightweight extension TfsExt13

Visual Studio - I want "Go To Definition" to open Object Browser, not "metadata"

In Visual Studio version 2002 and 2003 "Go To Definition" would find the selected type or member in the Object Browser. In 2005 onwards it opens a source window "generated from metadata" instead. How do I configure these newer versions to go to Object Browser? (In other words, I have the opposite problem to this one.)
Installing ReSharper makes this change, so I know it must be possible, but how do I do it without ReSharper?
As workaround you can create the following macro:
Sub GoToDefinitionUsingObjectBrowser()
DTE.ExecuteCommand("Edit.SelectCurrentWord")
DTE.ExecuteCommand("View.ObjectBrowser")
DTE.ExecuteCommand("View.ObjectBrowserSearch", DTE.ActiveDocument.Selection.Text)
End Sub
Then go to Tools/Options/Keyboard and assign hot key for this macro.
Tested in Visual Studio 2010.
I believe what re-sharper is doing is doing some hooks on that click event with the Visual Studio SDK I do not think there is any simple menu or location that can change that setting.
Instructions (pulled from CODE Magazine) edited down a bit to the part that pertainst to making the right click menus.
Creating a VSPackage
...The VS SDK installs a few more project
templates in Visual Studio, one of
them being the Visual Studio
Integration Package (Figure 1),
located under Other Project Types >
Extensibility on the New Project
dialog box.
After this standard dialog box, the
Visual Studio Integration Package
Wizard guides you through creating the
new package project:
Select a programming language. The wizard currently supports Visual
C++ and Visual C#. You can create or
pick a key file to sign the new
package.
Supply basic VSPackage information. The wizard prompts you
for details such as the company name,
VSPackage name, version, icon,
detailed information, and minimum
Visual Studio edition (such as
Professional or Enterprise) that the
package is designed to at this step.
This information goes into the Visual
Studio splash screen and About dialog
box and is also used to request a PLK
for the package (covered later).
Select VSPackage options. A package may add three types of
functionality: Menu Command, Tool
Window, and Custom Editor.
A menu command is a command added either to the menu
at the top of Visual Studio or
to a context menu (right-click).
When the wizard finishes its job, the
VS SDK adds core elements to the
solution to support the new package.
For instance, if you selected Tool
Window as part of the functionality
for the package, the project contains
a user control where you should place
the visual controls for the window.
The project also contains files for
.NET code to handle the functionality
that you will add to the package.
A CtcComponents folder contains
pseudo-C++ files (ctc files) where you
define things like menu, groups,
buttons, etc. Fortunately, Microsoft
is phasing out CTC files and replacing
them with a friendlier, XML-based VSCT
file format (which will ship in the
SDK for Visual Studio 2008).
The wizard creates a few other files
with .NET code required for the
plumbing of the package within Visual
Studio. Some of these files contain
classes that map the C++ constants to
.NET constants and other files contain
configuration information for the
package when it’s installed.
I know it has been a long time, but it appears, at least in newer versions of Visual Studio for the VB (Basic) language, to be an setting in the options.
Text Editor > Basic > Advanced
Under "Go to Definition".
I don't know why they don't have that for other languages...
Place the mouse cursor on the object you want to access on the object browser. Then, use the keyboard shortcut ctrl + alt + j, which will take you directly to the Object Browser window.

Resources