Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing C# Project References in a Subfolder

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.

like image 323
daedalus28 Avatar asked Feb 09 '11 11:02

daedalus28


People also ask

What is __ attribute __ in C?

The __attribute__ directive is used to decorate a code declaration in C, C++ and Objective-C programming languages. This gives the declared code additional attributes that would help the compiler incorporate optimizations or elicit useful warnings to the consumer of that code.

Why underscore is used in C?

You are looking at an example of C code obfuscation. The programmer uses a single underscore _ as the name for the second argument to the main function. He uses an old style declaration for main() somewhat equivalent to modern int main(int t, int _, char *a) .

Where do I write C code?

To write the source code of your first C program you need to open the Notepad++ text editor. The quickest way to do that in Windows 10 is to hit your Win key, type Notepad++ in the search window, and hit Enter. and paste it into the editor. Yes, this is your first C program!


2 Answers

Have you tried the AppDomain namespace?

AppDomain.CurrentDomain.AppendPrivatePath

http://www.vcskicks.com/csharp_assembly.php

like image 133
nik0lai Avatar answered Oct 02 '22 22:10

nik0lai


Or AssemblyResolve

public static class AssemblyResolver { 
    static AssemblyResolver() { 
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(delegate(object sender,  ResolveEventArgs args) {
            return Assembly.LoadFrom(...); 
        }); 
    }  
} 
like image 32
djeeg Avatar answered Oct 02 '22 22:10

djeeg