Groups | Blog | Home
all groups > visual studio .net ide > february 2004 >

visual studio .net ide : manually loading assemblies



Bob
2/18/2004 6:01:38 PM
In an addin, is there a simple way to manually load all referenced assemblies
for a given assembly? I'm having difficulty with anything that is not registered
in the GAC or in C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\PublicAssemblies. The AssemblyName class doesn't offer any
physical location information so I'm sort of stuck.

TIA,
Bob

Bob
2/19/2004 9:55:06 AM
Maybe my question was a bit vague... I'm loading the IDE's current project's
assembly and its referenced assemblies for reflection analysis.

But - ugh I can be a bit slow sometimes - you're right, I need to search for the
physical file. Everything should be found either in the output directory, or in
the reference paths, I just have to poke through there just like VS does.

thanks,
Bob

Carlos J. Quintero
2/19/2004 1:10:40 PM
[quoted text, click to view]


And that is correct, only the file name is required, not the folder which
could vary in each machine.

[quoted text, click to view]

I don´t understand completely the question but here you have some info:

- Given an System.Reflection.Assembly object, the GetReferencedAssemblies
method returns an array with the assembly names of the referenced
assemblies.

- If the assembly has a strong name, you can load it from the GAC with
Assembly.Load(strong name)

- If the assembly has not an strong name, you must search in each directory
with the same probing strategy used by the framework when the given assembly
tries to load the reference assembly and once you locate it in some folder
you can load it by full file name with Assembly.LoadFrom(full file name)

So far it has been for deployed assemblies (not in a development
environment). Now, for a development environment where you have VS.NET and
you use 3rd party assemblies for development (.NET data providers, controls,
etc.) these assemblies are installed not only in the GAC (for deployment)
but also in one of the following folders(for development, to appear in the
Add Reference dialog, .Net tab avoiding the use of the Browse button):

- Folders in the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders registry
key
- Folders in the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.x\AssemblyFolders
registry key
- Folders in the
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.x\AssemblyFolders
registry key
- Maybe some others that I don´t remember now

--

Carlos J. Quintero (Visual Developer - .NET MVP)


AddThis Social Bookmark Button