Reputation: 1637
I have a solution with multiple projects that all output dlls (except for the main application of course). Copy local is set to true for all of the references and everything is fine and dandy with dlls in the same directory as the exe.
My problem is that this is ugly. I'd like to put all the dll's in a subfolder (actually two subfolders down to be precise). How can I do this in Visual Studio 2008?
I've found a few questions that seem similar but I couldn't find the simple answer that I know has to exist.
EDIT: To be clearer, I want to know how to make the assembly loader look for references somewhere besides the operating directory. Users will be interacting with some of the other files in the directory, and the less clutter there is for them the better.
EDIT 2: I also want to avoid using the GAC. The application needs to be self contained.
Upvotes: 8
Views: 8892
Reputation: 920
Use the app.config <probing>
element to instruct the .NET Runtime to look in the subfolders to locate additional assemblies. See here.
Upvotes: 2
Reputation: 13842
I just publish an article that explain all these with details. Partitioning Your Code Base Through .NET Assemblies and Visual Studio Project
Here are the resulting guidelines of the article:
Upvotes: 0
Reputation: 6765
Or AssemblyResolve
public static class AssemblyResolver {
static AssemblyResolver() {
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(delegate(object sender, ResolveEventArgs args) {
return Assembly.LoadFrom(...);
});
}
}
Upvotes: 2
Reputation: 2655
Have you tried the AppDomain namespace?
AppDomain.CurrentDomain.AppendPrivatePath
http://www.vcskicks.com/csharp_assembly.php
Upvotes: 4
Reputation: 5968
You can't put those references in a subfolder. Since they will not be "seen" by your application's run-time.
The first place to put them is in your debug directory then in the Global Assembly Cache (aka GAC). Note that what you see in the (.Net) tab in Add Reference
dialog is actually the references in the GAC directory.
Note: If you use TFS as a backend source control, take notice that reference are not copied to the source control repository when you perform a check-in, rather you have to copy them manually.
Upvotes: 0