Ok, you need to set it up like this:
- c:\apppath\testapp.exe - your test apps exe file
- c:\apppath\testapp.exe.manifest - the - potentially embedded application manifest file
- c:\apppath\< emptyassm\ >emptyassm.manifest - A manifest describing your new assembly.
- c:\apppath\< emptyassm\ >empty.dll - the assembly dll
- c:\apppath\< emptyassm\ >empty.dll.2.manifest - the embedded manifest in the dll
So, you have your test application which contains an application manifest: which contains dependent assembly references for the app - including one you add to your custom dll assembly.
In the application folder you have the assembly manifest of the "emptyassm" assembly, which contains a file node referencing the actual dll, "empty.dll".
empty.dll embeds its own manifest, containing dependent assembly references on any public or private assemblies it requires.
This is the important point: the "emptyassm" assembly manifest, and the "empty" dll manifests are potentially different. The assembly's manifest file MUST NOT be embedded, but might share the dll manifest name IF you choose to name your manifest by the name of the dll.
Now, when the loader loads your EXE, it loads your EXE's manifest and adds it to the activation context. When the EXE's import table is processed, OR you call LoadLibrary, the loader first searches the activation context for an assembly manifest with a matching file node. If it finds a matching assembly, THEN it processess and loads the dll from the assembly location (the folder containing the assemblies .manifest) and it may, at this time, if there is no embedded manifest in the dll AND the dll and manifest have the same name, reuse the same manifest file to setup the dll's activation context.
IF you want to put the "emptyassm" manifest, and dll, in a different folder to your application folder, AND IF you are targetting Windows Server 2008, or Windows 7, or later, you can add a config file for your app :-
- c:\apppath\testapp.exe.config - app config file
The app config file can contain a probing node under the assemblyBinding node (config files look a lot like manifest files), with a privatePath="some relative path". In which case, the relative folder will be searched for assemblies.
My last response here has example files covering the process of creating an assembly from a dll, and referencing it from an exe :-
http://stackoverflow.com/questions/1969360/a-way-to-load-dll-from-central-repository
Just to clarify:
A win32 assembly is (At its simplest) a manifest file describing the assembly, and a dll.
They are always, in this model, located in the same folder so the file node of the manifest cannot contain any pathing information at all - only the name of the dll.
Assemblies can be shared - by giving them a strong version (and some digital signing) and installing them in Windows\WinSxS, or private.
Windows versions before 5.1 (Win XP) won't search for assemblies at all as this technology was only added in XP.
Windows 5.1 thru 6.0 (XP and Vista) will only search for private assemblies in the folder of the object with the active activation context :- If an exe references an assembly, then the folder containing the exe. If code in a dll references an assembly then the dll's folder is searched.
If you want to store your dll in a private location shared by several apps (For example) you MUST have a requirement of Windows 7 or later :-
Windows version 6.1 (otherwise known as Windows Server 2008, or Windows 7) and later will, additionally to the module folder, search the path specified as the privatePath element of the probing element in an application configuration file.
Application configuration files are always in the same folder as the exe or dll, and are named:
<exename>.exe.config
, or <dllname>.dll.2.config
(The reason for the .2. is there are potentially lots of manifests and configs embedded as resources, and the loader reserves resources id's 1...15. When searching the disk for a manifest of config file, it the resource id of the embedded resource would have been 1, the id is omitted, but any other number means it becomes part of the file name).