vsix opens visual studio - visual-studio-2010

I seem to have got my system into a bit of a pickle with respect to Visual Studio extensions.
Normally I would use Nuget.
When an extension is not on Nuget, I'd download the vsix file and double-click on it to start the installation process. But now, when I double-click on the vsix file, it opens it in the Visual Studio text editor, treating it as a file to be edited, rather than executing it as a file to be executed.
Anyone know how I can restore the correct, intended behaviour?
Thanks

First way: if you open regedit and see keys under HKEY_CURRENT_USER\Software\Classes.vsix, just delete that entire key. That should allow the global registrations in HKLM to take effect again.
Otherwise, right click on the file, Open With, and choose "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe".

Related

How to debug Visual Studio extensions

I'm just writing a VSIX extension for Visual Studio 2010 and can't figure out how to debug it.
One obvious method is to output messages. Extension template uses Trace.WriteLine(). But where to find it's output?
Visual Studio Extensions can be debugged like any other application. You just need to setup the debug experience to launch devenv with the loaded extension. Try the following
Right click on the project and select Properties
Go to the Debug Tab
Click on the radio button for Start External Program. Point it to the devenv.exe binary. On my machine it's located at
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
On a non x64 machine though you can remove the " (x86)" portion.
Then set the command line arguments to /rootsuffix Exp. This tells Visual Studio to use the experimental hive instead of the normal configuration hive. By default VSIX extensions when built will register themselves in the experimental hive.
Now you can F5 and it will start Visual Studio with your VSIX as an available extension.
The accepted answer by #JaredPar is technically correct, but suffers from the fact that you need to redo it for every developer, every time you get a fresh copy of the code, and any time the csproj.user file is deleted. When you do it that way, the settings are saved in the csproj.user file.
A better option is to put the settings in the csproj file so they are not lost. Unfortunately, Visual Studio does not allow you to do this automatically, so you need to manually add the settings. Luckily, the settings are the same for any project.
Right-click and unload the project, then right click again and edit the csproj project file file. In the XML, add the following to the first PropertyGroup, for example right after TargetFramework.
<StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)\devenv.exe</StartProgram>
<StartArguments>/rootsuffix Exp</StartArguments>
This has the following advantages;
It sets it up for debug and release
It runs whatever version of Visual Studio you are currently running
It is checked into source control, so every developer doesn't have to remember how to do it :)
As #MBulli states in the comments, if you have made the changes in the accepted answer, delete your *.csproj.user file because the settings in it will override the ones you added to the main csproj file.
The OutputWindowHelper.OutputString method writes to the 'General' output window pane (Ctrl Alt o). I added this line in my .csproj references to get this in VS 2013
<Reference Include="Microsoft.VisualStudio.Services.Integration, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
Also see this answer.
If you try to debug a UnitTestExtension, you should also attach the debugger to the vstest.*.exe processes like descibed here. Otherwise you might see the activate breakpoint but the debugger will never hit it.

Visual studio 2010 stuck

I've opened a XAML file in VS2010 that crashes Visual Studio.
The problem is that when I close VS and reload it again the XAML file automatically opens and crashes my VS again.
I don't know how to solve this loop.
Is there a way to open the solution with all files closed?
You could delete your solution's '*.suo' file. This file contain the information about the open editors. If you delete it visual Studio will not open any editor when loading the solution.
However you might lose some other customizations as well but in general there is nothing really important in this file and Visual studio will automatically create a new .suo file
I will try even a more violent method.
Move it into trash, and then bring up Visual Studio 2010.
Open another file in Visual Studio so your XAML file opening record will be washed out by the new one.
Close Visual Studio, and then restore your XAML file.
I'm pretty sure that Microsoft's file system won't track where your XAML file go and then tell Visual Studio to open it in the new location, but putting it in trash temporally is a great option.
Try temporarily move the xaml file to another location. (or rename) so VS cant find it, then you should be able to open.

Assign .vcproj files to Visual Studio 2008, when Visual Studio 2010 installed

I have encountered a strange error. I use Windows 7 x64. Visual Studio 2010 (VS10) and Visual Studio 2008 (VS08) are both installed. Now i want to make sure that when i doubleclick open a .vcproj file it is being opened by VS8 and not VS10. Now this seems like a trivial problem, but:
"righclick -> open with -> choose default program -> select devenv.exe of VS08 -> always open with" doesnt work. In fact after browsing for devenv.exe of VS08 it does not show up in the list/menue where it is supposed to be displayed.
This is very strange and annoying, maybe someone already encountered this error and know a solution.
I GOT IT! For the Express versions at least. I strongly suspect these instructions can be modified to apply to the full version. The names will change of course.
I spent a lot more time on this than I will ever save by being able to click through to the correct IDE, but darn it, I just hate to give up.
Here's the deal. Strangely, the associations seem to be keyed to the program file names. (Say, what?? That sure is the way it looks to me.) Both VC++ Express 2008 and 2010 are named VCExpress.exe. We'll give the 2008 version an alias. We'll also use a doppelganger to pull off something of a ruse.
Navigate to "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE". Make a copy of VCExpress.exe, (not a shortcut), and re-name it VCExpress-2008.exe. (It would probably do just to re-name the original and use the new name in step 3.)
Open regedit.exe. Create a new key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\VSExpress-2008.exe
Edit the (default) value in that key, to hold the string "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\VCExpress.exe" [sic]
Go through the drill with the file-association dialog again. Right-click, open with, choose default program, yada, yada, yada. Browse your way down to C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE and click on VSExpress-2008.exe.
VCExpress-2008 now shows up as a program in good standing, with its icon proudly displayed on the front page above the fold. (Don't tell the dialog, but you and I know it really points to VCExpress.exe, not the copy we made.) Click it.
Celebrate.
Ok i finally found a way. You can use the application "default programs editor" to mess with the standard file associations.

How to add a new file association to Visual Studio?

(Windows XP, Visual Studio 2010 Express (Web Developer))
I would like to add various file types to open in Visual Studio that it does not open by default, namely .js, .html, .shtml, .css, etc.
I tried looking for UI inside Visual Studio to add new file types, but I couldn't find anything, so I tried the naive approach of right clicking on the file -> Open With -> Choose Program -> Browse -> c:\program files\Microsoft Visual Studio 10.0\Common7\IDE\VWDExpress.exe. This almost works, except it starts a new instance of the IDE rather than opening a new tab the way .cs files do.
I've tried to go registry diving, exported the association for .cs files, and changing it to point to .shtml (for example), but this still spawns new windows.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.shtml]
"Content Type"="text/plain"
"PerceivedType"="text"
#="VWDExpress.cs.10.0"
[HKEY_CLASSES_ROOT\.shtml\OpenWithProgids]
"VSTA.cs.9.0"=""
"VWDExpress.cs.9.0"=""
"VWDExpress.cs.10.0"=""
[HKEY_CLASSES_ROOT\.shtml\OpenWithProgids\Shared]
#="Shared key to keep this from being removed with install/uninstall of side-by-side components."
[HKEY_CLASSES_ROOT\.shtml\PersistentHandler]
#="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
I strongly suspect that doing this is the wrong way to go about this, but I can't find a better solution. Is there one?
Ive had the same issue so downloaded VWD with SP1 along with VS.PHP 2.10. Right clicked on a .php file and chose 'open with vs.php 2.10', checked the checkbox on bottom which saves settings. Double clicking on a php file has been working since then. In order to be able to use it from a file manager like winscp i had to put 'explorer' as the editor executable. It works for my js html css and php files and opens them in the same VWD instance. Only pain may be that vs.php is to be paid for eventually and that you'd need to associate every extension you wish to work with.
After you use naive approach to associate file with VWDExpress.exe, find a command in registry and add /EDIT parameter. I don't know if this works for Express versions, but for full Visual Studio this opens file in already open Visual Studio instance.
Download Default Programs Editor and open.
In my case I was associating .php files to Visual Studio 11, and to do this I simply copied the settings for .cs files. I've noted all steps below.
FIle Type Settings > Context Menu
Search .php (or whatever association) - note you can multi-select
Click next
Click Add... under the list
Enter the following data:
Command name: Open
Program path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /dde
Now unfold the Advanced Settings, tick Use DDE Message, and click Edit. Add the following:
Message: Open("%1")
Application: VisualStudio.11.0
Topic: system
If you want to apply this to lots of files I suggest using the built in saving to registry option and creating a batch script with it.

How do I force Visual Studio 2008 to use an Open instance when double clicking a file?

Certain non-project files that I use Visual studio for (.build, .xml, free-roaming html and css files) are already associated with visual studio and open in it when i double click them.
How can I get them to open in an existing instance of visual studio? Right now If i double-click the same file twice, it will open two instances of visual studio, I'd like it just to basically ignore the second open attempt if there is already an instance of VS open.
Windows 7 vs2010 answer;
Because "Default Programs > Associate a file type or protocol with a program" is so useless, use regedit.
Navigate to HKEY_CLASSES_ROOT\VisualStudio.XXX.10.0\shell\Open\Command and add /edit to the end of the open with line, where XXX is the filetype you wish to affect.
Example .reg file for .cpp;
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\VisualStudio.cpp.10.0\shell\Open\Command]
#="\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.exe\" /dde /edit"
Ok Richard helped point me in the right direction a bit, but I think I found exactly what I want.
from an explorer window, go to Tools->Folder Options->File Types tab
find the extension you wish to change.
If there is a restore button click it.
Click Advanced
Click New... to create a new action.
I set the following:
Action: Open in VS 2008
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /dde
check use dde
DDE Message: Open("%1")
Application: VisualStudio.9.0
DDE Application Not Running: (left blank)
Topic: System
Hit Ok
Set the new action as the default.
Hit Ok, Hit Ok
Now that extension will behave exactly as described in the question. The file will open in an existing VS if visual studio is already open.
I also used this to fix a few extensions that got broken when I reinstalled VS 2005 after 2008.
Win 7/ VS 2012
You can right click a file, go to properties.
Then there is an "Opens With" line and a change button. But I don't see a way to force other command line options. VS2012 seems to use the open instance by default.
Which version of VS?
For 2003, there's VSEdit.
In 2005, well, that's the way it works for me out-of-the-box. A quick Google search found something that may help.
Hope that helps.
Later versions of Visual Studio also seem to have problems opening files via DDE from certain applications (e.g. in SSHCommunications' Secure File Transfer Client; Winzip and explorer seem to work fine). This still happens with the solutions given previously.
When IDE already loaded, the IDE focuses but gives error 'The template specified cannot be found. Please check that the full path is correct'
When IDE not loaded, it intermittently gives error 'The file cannot be opened because it is being used by another process. Please close all applications that might access this file and try again'. Trying again proceeds as 1)
You can get it working in all situations using a combination of all the previous posts!
Install the VSEdit application (as suggested by Richard/Jeff for .Net 2003), regardless of the version (or versions) of msdev that you use: the post by Sara Ford to which they refer recommends VSEdit for command line operation in VS2005 - it also seems to work for later versions.
Alter the DDE (Tools->Folder Options->File Types) as Jeff proposes but to open via VSEdit.exe instead of devenv.exe directly. Specifically:
Action: Open "C:\Program Files\PowerToys for Visual Studio .NET
2003\VSEdit\VSEdit.exe" /c "C:\Program Files\Microsoft Visual Studio
9.0\Common7\IDE\devenv.exe /Edit """%1"""" "%1" use dde: (checked) DDE Message: (left blank) Application: VSEdit DDE Application Not
Running: (left blank) Topic: System
N.B. The triple/quad quotation marks are deliberate - they add the first opened file (quoted) to the end of the launch command to prevent msdev complaining about the command line usage of the /Edit mode if launched. Obviously command paths will need changing for different installations.

Resources