Add Reference Dialog control
-
(this probably really belongs in the VS IDE board, but I'd rather Mr. Stewart took a read - apologies all) Is there a way to programmatically create the "Add Reference" dialog as seen in the VS.NET IDE? I'm aiming at creating a wizard to generate a particular type of component. During this wizard process, the user will need to select an existing .NET assembly (one that conforms to interface X). I'm wobbling between writing my own file chooser, but if the "Add Reference" dialog is a creatable control, I'd rather use that. Any ideas?
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
-
(this probably really belongs in the VS IDE board, but I'd rather Mr. Stewart took a read - apologies all) Is there a way to programmatically create the "Add Reference" dialog as seen in the VS.NET IDE? I'm aiming at creating a wizard to generate a particular type of component. During this wizard process, the user will need to select an existing .NET assembly (one that conforms to interface X). I'm wobbling between writing my own file chooser, but if the "Add Reference" dialog is a creatable control, I'd rather use that. Any ideas?
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
Currently, the way the Add Reference works is as follows: Go to the registry Under the Framework it get the list of directories Under each directory it gets each item in the GAC You could probably do something similar where you have either a number of well-known directories or a way of dynamically constructing a directory list. For each assembly in each directory, you would then do an Assembly.Load and check to see if it exposes IMyInterface. ______________________________ The Tao gave birth to machine language. Machine language gave birth to the assembler. The assembler gave birth to ten thousand languages. Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao. Beauty exists because we give a name to C#. Bad exists because we give a name to COBOL.
-
(this probably really belongs in the VS IDE board, but I'd rather Mr. Stewart took a read - apologies all) Is there a way to programmatically create the "Add Reference" dialog as seen in the VS.NET IDE? I'm aiming at creating a wizard to generate a particular type of component. During this wizard process, the user will need to select an existing .NET assembly (one that conforms to interface X). I'm wobbling between writing my own file chooser, but if the "Add Reference" dialog is a creatable control, I'd rather use that. Any ideas?
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
As theRealCondor said, you go to the registry. Enumerate the keys under HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders. If you want, you could also have your dialog enumerate the GAC using fusion.dll. Read Undocumented Fusion[^] here on CodeProject for more details. And, no, this really doesn't belong in the IDE forum, since you're only talking about programming something like the IDE has. Just my opinion, anyway.
Microsoft MVP, Visual C# My Articles
-
(this probably really belongs in the VS IDE board, but I'd rather Mr. Stewart took a read - apologies all) Is there a way to programmatically create the "Add Reference" dialog as seen in the VS.NET IDE? I'm aiming at creating a wizard to generate a particular type of component. During this wizard process, the user will need to select an existing .NET assembly (one that conforms to interface X). I'm wobbling between writing my own file chooser, but if the "Add Reference" dialog is a creatable control, I'd rather use that. Any ideas?
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
See ExecuteCommand Method (DTE Object). You'll want "Project.AddReference", I think...
DTE.ExecuteCommand("Project.AddReference", "");
Try it in the immediate window by typing "Project.AddReference" It'll bring up your requested dialog.
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me -
Currently, the way the Add Reference works is as follows: Go to the registry Under the Framework it get the list of directories Under each directory it gets each item in the GAC You could probably do something similar where you have either a number of well-known directories or a way of dynamically constructing a directory list. For each assembly in each directory, you would then do an Assembly.Load and check to see if it exposes IMyInterface. ______________________________ The Tao gave birth to machine language. Machine language gave birth to the assembler. The assembler gave birth to ten thousand languages. Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao. Beauty exists because we give a name to C#. Bad exists because we give a name to COBOL.
Thanks for the replies guys...I'll probably end up going with the Registry iteration route. Kinda fits what I was thinking before I came up with the Add Reference idea.
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
-
See ExecuteCommand Method (DTE Object). You'll want "Project.AddReference", I think...
DTE.ExecuteCommand("Project.AddReference", "");
Try it in the immediate window by typing "Project.AddReference" It'll bring up your requested dialog.
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - meNifty...never screwed much with the Command Window. Nice to know what it can do. :)
Jeremy Kimball I have traveled the gutters, lo these many days, with no signs of life. Well met. -brianwelsch
-
As theRealCondor said, you go to the registry. Enumerate the keys under HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders. If you want, you could also have your dialog enumerate the GAC using fusion.dll. Read Undocumented Fusion[^] here on CodeProject for more details. And, no, this really doesn't belong in the IDE forum, since you're only talking about programming something like the IDE has. Just my opinion, anyway.
Microsoft MVP, Visual C# My Articles
What exactly is the point of enumerating GAC assemblies? It's not like VS will let you add references to assemblies that are sitting in the GAC.