Watch for addition of a referenced library to a project (Visual Studio 2008 plug-in) - visual-studio

I am hoping someone can help me with this. What I have been looking around for but can't seem to find is if there is someway to add an event, or anything else that will allow a visual studio plug-in to watch for an external reference to be added to a currently open solution / project?
Or even better yet would anyone happen to know of an add-in that automatically adds all controls from a referenced dll into the visual studio toolbox?
Thanks.

Not exactly what you asked, but I've written a Visual Studio 2008 Integration Package, and if I recall correctly I could override the "add reference" method, as well as inherit the "reference node" and thus change its behavior, for example its constructor.
This functionality might be missing from an add-in (which is more limited than an integration package), so you might consider writing a package instead.

I have written a macro that will change a file reference to a project reference if you add the project to the solution (and vice versa), but I don't think that's what you want?

Related

How to "force the WiX .exes to run out-of-process"

There is a bug in the WiX plugin for Visual Studio where file locks on referenced DLLs are not properly released. Therefore, you have to restart Visual Studio every time you want to recompile a custom extension DLL or any assembly referenced by it.
This is a known bug, but the issue was closed because there seems to be a solution / workaround:
You can force the WiX .exes to run out-of-process to avoid the lock
MSBuild has.
I don't understand how to achieve this. I checked...
the properties of my WiX setup project
the properties of the extension assembly (C# class library)
all Visual Studio settings
the available command line arguments of candle.exe
...but did not find anything. What am I missing? How do I apply this workaround?
I'm using WiX 3.10 and Visual Studio 2013.
The example that I've seen several times around the web is to add <RunWixToolsOutOfProc>true</RunWixToolsOutOfProc> to the Wix Installer's project file within a property group. Unfortunately, documentation of this feature has thus far eluded me.

Is there a simple way to include a missing reference to an assembly in Visual Studio?

I'm using Visual Studio 2012.
In most solutions I have lots of projects which reference each other.
It's quite time consuming to always add the reference manually.
Is there a simple way (either built-in or via extension) to include a missing reference to an assembly in the own solution similar to the way missing usings are resolved?
Resharper does exactly this. If there's a class that is defined in another project in the solution, it offers you to reference that class and import the namespace. All you do is press "Alt+Enter, Enter" to pop up context menu and select the first option.
As mentioned before, resharper will be a good solution for your request. but if you are looking for a free visual studio extension that does the same you can use 'WoVS Quick Add Reference' extension.
Some info: http://ihadthisideaonce.com/2011/07/29/recommended-wovs-quick-add-reference/
Download link: https://visualstudiogallery.msdn.microsoft.com/dc06b54c-b6c4-4cf5-8203-a09c6979e881/
I hope it supports your questions..
This extension at least offers a way to add references to GAC assemblies
visual studio gallery
But it requires CodeRush and so also isn't a free choice.

visual studio 2010 control library references

I wrote a control library using visual studio 2010, I'll call it MyLibrary. MyLibrary references another control library I have that we'll call AnotherLibrary. I also have a clean virtual machine (CVM) and I've added AnotherLibrary to the GAC on the CVM. Using the CVM, I create a new WinForms project, add MyLibrary.dll to the toolbox, and drop one of the controls onto the form. Visual Studio will add MyLibrary.dll AND AnotherLibrary.dll to the references, even though AnotherLibrary.dll is in the GAC (and isn't needed). I can remove AnotherLibrary.dll from the references and everything is fine.
Is there a way to prevent visual studio from adding AnotherLibrary.dll in this scenario?
Edit: I've given this some thought and I have an example. When you add a TabControl to a parent control in the designer, visual studio won't add System.Design to the references, even though the TabControl depends on it. So, surely there is a way to do this?
You still need the reference. Just like you need the reference to, say, System.dll which is also in the GAC. You just don't need the copy of the assembly in your bin\Debug directory. That you happened to not break the compiler by removing the reference is possible, especially since is this is an indirectly used assembly. But some odds that you'll eventually run out of luck.
In general you really want to avoid using the GAC on your dev machine. Because you care about specific versions of an assembly when you, say, create a bug fix. You get those specific versions from source control, not the GAC.
Doesn't it make sense that it would automatically include all dependencies? It cannot assume that AnotherLibrary is in the GAC on every machine you might want to deploy your code on. Of course as you mentioned you can manually remove it....

Visual Studio and finding References fast

I am building a class library, and I am getting an error and I know that I need to add a reference.
Does VS have a feature where it will find the required library automatically, or do I need to know where the library is located and add the reference manually.
In java/eclipse, you may right click like and jars will be found automatically if on the build path, does VS have this concept?
We use Resharper for that feature and a lot of many other improvements to the IDE.
Couldn't use Visual Studio anymore without it.
ReSharper has a feature to do this. If it knows which assembly has the referenced type, it will suggest adding that assembly as a reference.
If you go alt+shift+F10 on the item that's missing a using it will suggest you the appropriate option (but you obviously need to have the assembly referenced already).
I am not aware of any way of running this on all the items in a single go though (without ReSharper).

Visual Studio Go to Definition

Go To definition in Visual studio 2005 works only for files that are in my project. It never works for files that are included in external libraries like mfc. When I say Go To Definition for mfc function it always shows me the header file . Is this expected behavior?
And also how does this whole thing Go To Definition work?
Thanks
I'd make the small investment required in Visual Assist. Besides all the great features it offers, it has the Alt+G command which works way better than the Visual Studio go to definition :)
For the MFC source files (at least the Feature Pack ones) I learned to find out what folder are they in (usually at C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc) and add that folder to the Find in Files dialog.
It's not as direct as Go to Definition, and you may have to browse among the find results, but it works...
Note: I second #flippy's answer of Visual Assist, it's really great.
External libraries are references to their compiled DLLs rather than the source when referencing your own projects.
The idea is that you don't need any more than the interface to external classes, but, if you would like to see the internals of DLLs you can use a tool such as Reflector.
Yes only the interfaces for MFC will be given in header file.Unless it is implemented with Template you will not be able to access the actual definition.The dlls have implementation for those interfaces.
Well if you think about it logically, as far as visual studio knows the only definition of the MFC object that is available is the definition it sees in the associated MFC header file, so unless you actually have the entire source for MFC it won't be able to look anywhere else.
The way that intellisense/go to definition works is via a file that is created when you compile the application. It stores a mapping between variables/functions and where they are declared (or could potentially be declared, in polymorphic situations), and when you right click to say "go to definition" it references that file.
Yes this is the expected behavior. Only the declarations (header files) of the MFC code are available on your box and hence that is the only location that it can take you to.
What are you expecting it to show?

Resources