Visual Studio 2010 Toolbox Is Empty - visual-studio-2010

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.

Related

Visual Studio 2017 code colors not working correctly [duplicate]

When I want to edit C# Unity scripts, they open in Visual Studio. It is supposed to provide auto complete for all Unity related code, but it doesn't work.
Here you can see the missing functionality:
As seen, the transform object does not open the autocomplete menu.
Unity version: 5.5.2f1
Visual studio 2015
Visual Studio Tools for Unity is installed
There is no auto-completion because the script says "Miscellaneous Files" instead of the of the name of the Project. Take a look at the image below that came from the video in your question:
The "Miscellaneous Files" message can happen for many reasons:
It can happen when you open your Unity C# file from another folder instead of opening it from Unity Editor.
This can also happen because Unity crashed while Visual Studio is still open therefore corrupting some files.
It can happen because Unity was closed then re-opened but is no longer connected to Visual Studio. When Visual Studio is opened you get "Miscellaneous Files" and no auto-completion.
This can happen when Visual Studio Tools for unity is not installed.
When you create a script from Unity then quickly open it before Unity finish processing it or before the round icon animation stuff finish animating.
Most of the times, restarting Unity and Visual Studio should fix this.
I can't tell which one is causing the problem but I will cover the most likely solution to fix this.
Fix Part 1:
Download and Install Visual Studio Tools for unity from this link. Do this while Unity and Visual Studio are both closed.
From Unity Editor, go to Edit → Preferences... → External Tools. On the External Script Editor drop down menu, change that to Visual Studio 2015.
Fix Part 2:
If newly created C# files are coming up as Miscellaneous then follow the instruction below:
From Visual Studio, go to Tools → Options... → Tools for Unity → Miscellaneous. Under Show connectivity icon, set it to true then restart Visual Studio.
When you re-start, connection icon should now be available in Visual Studio. Click it then choose the Unity instance to connect to. The red 'x' icon should now turn into a brown checkmark icon. Now, when you create a new C# file in Unity, it should open without saying Miscellaneous.
Fix Part 3:
Still not fixed?
Re-import project then open C# Project.
Close Visual Studio.
From Unity, re-import project by going to Assets → Reimport All.
Now, open the project in Visual Studio by going to Assets → Open C# Project. This will reload the project and fix possible solution file problems.
Fix Part 4:
Still not fixed?
Fix each C# file individually.
Click on Show All Files icon.
Select the script that doesn't do auto-complete then right-click and select Include In Project.
Fix Part 5:
Not fixed yet?
Credit goes to chrisvarnz for this particular solution which seems to have worked for multiple people.
Close Visual Studio
Go your project directory and delete all the generated Visual Studio files.
These are the files extensions to delete:
.csproj
.user
.sln
Example:
Let's say that the name of your Project is called Target_Shoot, these are what the files to delete should look like:
Target_Shoot.csproj
Target_Shoot.Editor.csproj
Target_Shoot.Editor.csproj.user
Target_Shoot.Player.csproj
Target_Shoot.Player.csproj.user
Target_Shoot.sln
Do not delete anything else.
Double click on the script again from Unity which should generate new Visual Studio file then open Visual Studio. This may solve your problem.
Fix Part 6:
If not working, check if you are having this error:
The "GetReferenceNearestTargetFrameworkTask" task was not found
Install Nuget PackageManager from here.
Restart Visual Studio.
See this answer for more information.
Fix Part 7
Make sure all of the projects are loaded.
In Solution Explorer it should tell you # of # projects.
If all of the projects are not showing, right click on "Solution (# of # projects)" and click Load Projects.
Try this,
In Unity Editor Go to Menu, Click on Edit -> Preferences -> External Tools -> External Script Editor. Set it to Visual Studio (your installed version of VS).
Now in Menubar go to Edit -> Project Settings -> Player Settings -> Other Settings -> Under Configuration -> Check API Compatibility Level -> Change it to your installed .Net version. In my case I set it to .Net 4.x
Now if Visual Studio is running already go to Visual Studio, it will ask to reload project. Reload the project. Check if it works, if not close Visual Studio. Now Open cs file from Unity Editor, and now it should work.
I found another way to fix this issue in a more convenient manner:
Select the broken file in Solution Explorer.
Open its Properties.
Switch field "Build Action" from "Compile" to "None".
Then switch it back to "Compile".
This will kill the synchronization between Unity and Visual Studio somehow.
The next time Visual Studio will reload the project, it will prompt a warning.
Just click on "Discard".
If you have done all of the above and still isn't working , just try this:
Note: you should have updated VS.
Goto Unity > edit> preference >External tools> external script editor.
Somehow for me I had not selected "visual studio" for external script editor and it was not working. As soon as i selected this and doubled clicked on c# file from unity it started working.
I hope it helps you too.
Unload and reload the project, in Visual Studio:
right click your project in Solution Explorer
select Unload Project
select Reload Project
Fixed!
I found this solution to work the best (easiest), having run into the problem multiple times.
Source: https://alexdunn.org/2017/04/26/xamarin-tips-fixing-the-highlighting-drop-in-your-xamarin-android-projects/
This page helped me fix the issue.
Fix for Unity disconnected from Visual Studio
In the Unity Editor, select the Edit > Preferences menu.
Select the External Tools tab on the left.
For External Script Editor, Choose the Visual Studio version you have.
Click regenerate Files
You Done
Select project in Visual Studio
Click "Refresh" button
I hit the same issues today using Visual Studio 2017 15.4.5 with Unity 2017.
I was able to fix the issue by right clicking on the project in Visual Studio and changing the target framework from 3.5 to 4.5.
Hope this helps anyone else in a similar scenario.
Two Alternative Options:
Fix 1
#singleton pointed me in this direction. Instead of changing the target in Visual Studio you should change it in Unity since the project is auto-generated.
First delete the auto generated Visual Studio files:
.csproj
.user
.sln
Then from within Unity go to PlayerSettings and under 'Other Settings' change the 'Scripting Runtime Version' from Stable 3.5 to Experimental 4.6.
However, that didn't fix it for me.
Fix 2
I noticed all of the references to Unity related code was marked with a yellow warning. Check your error logs and see if this is the case. In particular see if you get the following error: getreferenceNearestTargetframeworkTask
If so try:
Start Visual Studio Installer again.
On the Build Tools 2017, click Modify,
Ensure that "Nuget targets and build tasks" are ticked. This should become ticked if you click on Universal Windows Platform development.
Update 2020 with Visual Studio Community 2019 and Unity 2019.3:
Open Visual Studio Installer as Administrator, select to modify your current installation and add "Game development for Unity"
If you add a new c# script in Unity now, and open it (automatically) with Visual Studio, it is not described as "Miscellaneous" at the top of the window but with "Assembly-CSharp", and the autocomplete works.
i found my solution by creating the .cs file from visual studio itself instead of unity editor
right click on project folder in solution explorer
add > new item
type "unity" on the search field on the top right
select "CSharp MonoBehaviour"
name your script on the bottom and click Add
In my case, correct .net version was not installed on my PC. I install the .net 3.5 on my pc and that worked for me.
For Windows or macOS:
Download/Install the Visual Studio IDE (with Unity Tools)
When installing, make sure you include installation of
Game development with Unity
Then using Unity (you can double click one of your C# files), open a new C# project and the Visual Studio IDE should open with your new project structure.
From there, you should be able to see what you are looking for.
For example:
For Linux (suggestion):
Try Monodevelop - Additional Information, it provides code completion/hints.
My autocomplete also didn't work because Visual Studio Tools for Unity wasn't installed. So, after you install that, delete the auto generated Visual Studio files. Others said that you open file again and the problem is solved but it's not.
The trick is: instead of normally double-clicking the file, you need to open the C# file from Unity by right click and then "Open C# Project".
The issue I faced was that the C# Project was targeting a different .NET Framework (4.7.2), whereas the Unity project had a different target (.NET 3.5).
I fixed this by changing the target in Unity as-
File -> Build Settings -> Player Settings -> Other Settings -> API
Compatibility Level : Set it to the .NET version you already have
installed (Check your .NET Version here). In my case, it was 4.x
After this, Visual Studio worked perfectly and autocorrect was fixed too.
Try pressing Ctrl + Alt + Space (which toggles between suggestion and standard completion modes)
For some odd reason, the "Game development with Unity" tool can become disabled in Visual Studio.
To fix this..
Open Visual Studio
Go to Extensions → "Manage Extensions" → Installed
Find "Visual Studio 2019 Tools for Unity"
If it is disabled, enable it
Restart VS
Credit to Yuli Levtov's answer on another Thread
The following works for me.
Go to Edit->Preferences->External Tools->External Script Editor Select Scripting Editor
I solved to install the same version of .NET on WIN that was configured in my Unity project. (Player Settings)
Go to Options on the Tools menu and then select Documents in the Environment node. (If Documents does not appear in the list, select Show all settings in the Options dialog box.)
Put a tick on "Miscellaneous files in Solution Explorer" and Click OK. (This option displays the "Miscellaneous Files" node in Solution Explorer. Miscellaneous files are files that are not associated with a project or solution but can appear in Solution Explorer for your convenience if you tick this option.)
Locate your file in the Solution Explorer under "Miscellaneous Files". Then drag and drop your file to where it should belong and voila! This will copy the file to where you drop it. You may now safely delete the older file under Miscellaneous Files folder if you wish to do so
Credits: https://stackoverflow.com/a/47662523/10471480
In case Scripts folder is not visible:
Click on "Show all files" in Solution Explorer
Locate the Scripts folder.
Right Click on Scripts and select "Include in Project"
Keep in mind that if you are using the ReSharper tool, it will override the IntelliSense and show it's own. To change that, on VS, go to Extensions -> ReSharper -> Options -> IntelliSense -> General then choose Visual Studio and not ReSharper.
Before restarting and/or re-installing VS, First try opening any other of your projects to see if Intellisence works, if it does, then issue probably lies with your current project. First, most probable victim would be the NUGET packages with pending updates. To Fix this,
Right click on references
Proceed to Manage NUGET Packages Under NUGET Packages
proceed to updates Install Updates and recheck Intellisence
I tried all of these but ended up finding out that I needed to right-click the solution in Solution Explorer and add existing items and find the C# assembly file in Window's Explorer. There seem to be a bazillion different problems that give you this error, this is likely the most simple solution. If you double click on your script from unity, it does not seem to drag the assembly along.
Another possible fix:
In the project window, click on the Assets folder
Right click, and Create -> C# Script
Double click that, and wait.
For some reason, this work.
None of the above solutions worked for me. However I opened the ProjectName.CSPROJ file and manually added the new file and it worked like charm
What worked me is that I copied all the code inside the broken class and removed that file.
Then, I opened an empty file with the same name and pasted back.
Result: beautiful syntax highlights came back!
"Preferences" -> "External tools" -> set you exteranl tool
Thats one fix. Also for VS you can use ReSharper by JetBrains, but I recommend use Rider. That one is also free for students.
It provides less performance than visual studio, but more than VS+Resharper definitely.
Have a good day, mate)
Try with combination: Ctrl + Alt + Space
one of the above methods are worked for me and I just found a solution to this problem,
1. First, go to the project directory and delete .sln file
2. Second, go to unity and double click your script. Then Visual Studio will be open with an error,
Then click ok and close Visual Studio editor.
Finally, turn off your Windows Defender and then go to your project directory and there will be .csproj file. Just double click and open this from your Visual Studio editor and open the scripts folder inside the assets folder and open the scripts and autocompletion will be working perfectly fine.
These actions solved the problem for my projects in Visual Studio 2022
FIX 1
Solution
Assembly-CSharp (right-click)
Load Entire Dependency Tree
FIX 2
Solution
Assembly-CSharp
References
Double click on any lib to force loading

Is there a Command in Visual Studio for "Navigate to this item in TFS Source Explorer"

I want add a command to the R-Click context menu in the Solution Explorer that would navigate the TFS Source Explorer window to the right location corresponding to the item in question.
However I can't see how to do it simply without writing a VS extension, which I want to avoid at all costs.
It's not that I don't want extensions. I just don't want to write a custom one. Previously I'd be able to use macros but those were removed in these versions of Visual Studio.
The VSCommands extension will give you the option to locate a file in TFS and in the Solution Explorer
The Locate in TFS extension adds a context menu entry Locate in TFS to Solution Explorer and Open Tabs.

VS2010 "Add Item" directory change

Is there any way to change the default directory Visual Studio 2010 uses when you add a source file through Add -> New Item?
Add New Item simply adds the item based on which project directory you're currently in or have selected in your Solution Explorer. If you want to change where it gets added then select the target location in the Solution Explorer first.
This behavior is obvious when right-clicking in the Solution Explorer, but it's also the same when using Project -> Add New Item....
Since my comment seems to be the actual answer, I repost:
In the toolbar of Solution Explorer, there's a button "Show all files" (or similar, I'm using the German version). This switches the view to directories, rather than filters. In this view, you can right-click on the desired target folder to add items.
This does not actually change the default directory, but since you have to click somewhere anyway to add an item, this is the easiest approach.
Note that even when only using Visual C++, I'd recommend the Productivity Power Tools extension, which comes with Solution Navigator. In C++, this is not as powerful as with .NET, but it still has several features that are useful in C++ and can fully replace Solution Explorer.
Try going to tools -> options -> Project and Solutions.
I know this post is old... but maybe someone will stumble upon it... like I did today...
I had the same "problem":
I have a dedicated directory for icons.
When I need to add an icon to the resource file, Visual studio takes me to "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"
To fix the problem, after I "browsed" to the desired folder, I right-clicked the favorites of the "open file" dialog and selected "add current location to Favorites".
Next time you will get this dialog, you simply have to look for the folder in the favorites, and click it.

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 add TFS bindings to a Visual Studio 2010 project?

There's a question already discussing how to add project/solution bindings to TFS, however it seems to only apply to Visual Studio 2008 (I am unable to find the "Change Source Control" dialog in VS2010).
I have a solution and source code on my local machine already in TFS, however it does not have TFS bindings (the thing that produces the padlock icon in the Visual Studio Solution Explorer and allows automatic checkout).
How can I add bindings to an existing TFS project using Visual Studio 2010?
In VS2010 check Tools>Options>Source Control and see if set to TFS. If not that might be why you don't see File->Source Control->Change Source Control.
I ran into this problem and, for me, the issue was that my solution was offline with respect to TFS. Upon trying to change source control, I received a message stating that it is already associated with source control but is offline. I placed the solution on-line, per my recollection, using the File->Source Control->Go Online menu option and this seemed to fix the problem.
Go to the source control explorer under Team Explorer, where you can see your repository. Right click on the top folder that maps to the folder on your local machine. There's an option called "Map to local folder". Map this to the folder on your local machine. This will set up all the bindings for TFS for your project.
I had the same problem and the following steps solved it for me in VS 2008.
Unfortunately, I didn't record the exact steps and don't want to add a new project to our TFS to try again, so the steps are from memory.
Go to File Menu -> Source Control -> Open from source control
Select solution file from TFS hierarchy
Accept any warning about project already being on local disc
A popup dialog comes up saying something along the lines "This solution is already under source control, but no bindings exist. Do you want to add them?"
A selector shows all projects in a grid and allows adding the required bindings. Add TFS server setting to each project (select all lines in grid at once and press a button at the top. I can't remember what it was called, but it was fairly obvious).

Resources