Using VS2005 and vb.net ... I have a project that is an api for a datastore that I created. When compiled creates api.dll. I have a second project in the same solution that has a project reference to the api project which when compiled will create wrapper.dll. This is basically a wrapper for the api that is specific to an application. When I use wrapper.dll in that other application, I have to copy wrapper.dll and api.dll to my new application. How can I get the wrapper project to compile the api.dll into itself so that i only have one dll to move around?
You'll probably have to use a tool, such as ILMerge, to merge the two assemblies.
There's an easier way. Just create shortcuts (called linked files in Visual Studio-ese) in your wrapper.dll project that point to the source files in api.dll. That will compile your source directly into wrapper.dll.
I think you could compile api.dll as a resource into wrapper.dll. Then manually access that Resource out of api.dll and manually load it. I have manually loaded assemblies from disk, so loading one from a Stream should not be any different.
I would try including the dll in your project as a file, similar to including a text or xml file (in addition to its project reference for compilation). Then I would set the build action to "Embedded Resource." Within wrapper.dll, I would use the Assembly object to access api.dll just like any other embedded resource. You will then also want to load the assembly using Assembly.Load http://msdn.microsoft.com/en-us/library/system.reflection.assembly.load.aspx
@dannysmurf ... literally a windows shortcut or is there some way to add a "linked file" through vs? I cant find anything referencing the ability to add a linked file.
@Jas, it's a special feature in Visual Studio. The procedure is outlined in this blog entry, called "Sharing a Strong Name Key File Across Projects". The example is for sharing strong name key files, but will work for any kind of file.
Briefly, you right-click on your project and select "Add Existing Item". Browse to the directory of the file(s) you want to link and highlight the file or files. Insted of just hitting "Add" or "Open" (depending on your version of Visual Studio), click on the little down arrow on the right-hand side of that button. You'll see options to "Open" or "Link File" if you're using Visual Studio 2003, or "Add" or "Add as Link" with 2005 (I'm not sure about 2008). In any case, choose the one that involves the word "Link". Then your project will essentially reference the file - it will be accessible both from the original project its was in and the project you "linked" it to.
This is a convenient way to create an assembly that contains all the functionality of wrapper.dll and api.dll, but you'll have to remember to repeat this procedure every time you add a new file to api.dll (but not wrapper.dll).