Reputation: 31743
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>
Upvotes: 2
Views: 2165
Reputation: 67198
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 a WM_SETTINGSCHANGE
might 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.LoadFrom
to 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
.
Upvotes: 4
Reputation: 11729
You can't do it directly with "Add reference" dialog. An exe file expects the dll to be in the same path of the executable file or they should be registered (and I don't know well how this works). Add reference dialog copy those dlls only in that path.
The only idea I have is dynamic dll discover which is good (for late bynding, see Mef), however I don't know if with compact framework 3.5.
The best solution maybe it's to add the dlls to the search path for the exe file, this question is the only good resource I found so far: How to save DLLs in a different folder when compiling in Visual Studio?
Upvotes: 0
Reputation:
You should be able to place the DLLs you need anywhere you want.
Obviously, locating them in your project's folder structure makes sense!
To add a reference to the DLL in your project's folder structure, you should just be able to Right-Click the References Section and select Add Reference.
Notice in the screenshot that SQLite.Interop.066.DLL is just visible in the dialog box. That was how I added it to my project.
Hope this helps.
Upvotes: 1