I am developing a Windows CE App using Visual Studio 2008 and the Compact Framework 3.5.
Now I want to place the required dlls in a subfolder to the main exe file. Is that possible?
This solution does not work for Windows CE.
Edit:
I want the dependencies to live in a subfolder on the client device.
Currently my folder structure looks like this (everything in a single directory)
-- folder\
------ main.exe
------ controls.dll
------ webservice.dll
------ businesslogig.dll
------ nlog.dll
what I want:
-- folder\
------ main.exe
------ lib\
--------- controls.dll
--------- webservice.dll
--------- businesslogic.dll
--------- nlog.dll
this is possible on the desktop with a setting in the app.config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
The compact framework doesn’t support setting the probing path in the app.config file. There are a couple things you could try as a workaround though.
My first guess would be to add the subfolder to the system loader’s search path, though I don’t know that I’ve ever actually tried it for managed assembliess. To extend the loader path, simply add your path as another string in the MULTI_SZ registry key at
[HKLM\Loader\SystemPath]. I’m also not certain if this requires a soft reset to get the OS to pick up the change. Broadcasting aWM_SETTINGSCHANGEmight also be worth a try.The second option for managed assemblies is to manually load the assembly when you come up – before you use any classes from the target. Call
Assembly.LoadFromto load it up and at that point the CLR will be able to load it.The second option for native DLLs is to call a P/Invoke on the DLL with a full path to the target. Once loaded by the first P/Invoke, any further calls to the dll name (even without a path) will properly resolve as it will just use the internal handle retrieved by
LoadLibrary.