views:

732

answers:

3

I'm currently developing a visual studio add-in, however when I close visual studio and shutdown my machine and come back the next day, I cannot build the add-in because it is currently loaded in visual studio. How do i fix this problem so I don't have to manually remove delete and reinstall the add-in every time I wish to debug or change my add-in?

A: 

You can set the behavior of the addin and how it loads, I'd set it to 'load on demand' which I'm currently trying to find you some information on.

I can't find anything official but if you go to the Setup project, right click and select "View Registry" it'll show you all the registry keys that are created. Navigate down to the level for your addin and change the 'LoadBehavior' from '3' to '2'.

From then on you should be able to load your add-in using the Addin Manager.

I'll try and update with more information when I can get it, hope it helps.

PintSizedCat
I dont have a 'setup' project, I've just got a project with a C# addin which when launched spawns a second visual studio with the addin installed. But if I close both visual studios and start a fresh instance the original visual studio now has the addin loaded, preventing me from building
Tom J Nowell
I have to run now but I'll look in to it later for you.
PintSizedCat
+2  A: 

AddIns are usually loaded by .AddIn file which is placed in one of these locations

C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins\ C:\Documents and Settings\Computer.User\My Documents\Visual Studio 2008\Addins

So when I do AddIn development, I start Visual Studio with special .bat file. I also use the AddIn when working on other projects, so there are additional complications. Here is an example of the file I use:

:: My installed .AddIn file goes in All Users directory
move "C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins\Sample.AddIn" "C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins\Sample.AddIn_"

:: just in case it got left from the previous session
del "C:\Documents and Settings\Computer.User\My Documents\Visual Studio 2008\Addins\Sample_dbg_.AddIn"

:: start Visual Studio and open AddIn solution
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" D:\dev\Sample.sln /resetaddin Sample.Connect

:: this will execute after Visual Studio is closed
del "C:\Documents and Settings\Computer.User\My Documents\Visual Studio 2008\Addins\Sample_dbg_.AddIn"

:: This is needed because my installed AddIn, and the one I'm developing are in different directories, yet have the same name. That confuses studio and this line sets things straight
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /resetaddin Sample.Connect /Command File.Exit

:: restore installed AddIn file
move "C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins\Sample.AddIn_" "C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins\Sample.AddIn"

exit

I also do this on Prebuilt event in AddIn project:

copy "$(ProjectDir)\Sample_dbg_.AddIn" "C:\Documents and Settings\Computer.User\My Documents\Visual Studio 2008\Addins\Sample_dbg_.AddIn"

Also you could look into Visual Studio command line parameter /rootsuffix , but I wasn't able to find a solution around that.

Juozas Kontvainis
A: 

This is what worked for me:
Pre-build event that renames the target as target.locked

DavGarcia