I actually have a solution for this. Or rather,
I am closing in on one.
If you use SharpDX.Direct3D9 or
SharpDX.Direct3D10 it's likely you need
D3DX9_43.dll and D3DX10_43.dll respectively.
You are right that these DLLs are located in
the C:WindowsSystem32 and C:WindowsSysWow64
directories after installing the
DirectX10 June 2010 Runtime.
However, your users don't want a 100MByte
download (too right)...
EDIT: Update. I now have this
Include the libraries you need as
dependencies as embedded resources in your Managed
- Make sure you include the x86 and x64 versions
of the library in separate folders.
- e.g. D3DX9_43.dll from C:WindowsSystem32 is
the 64bit version on x64 machines, should be
included as an embedded resource in
- D3DX9_43.dll from C:WindowsSysWow64 is the
32bit version (go figure!) on x64 machines and
should be included as an embedded resource in
Now create a DLL loader using this technique to selectively
write out the correct (x86 or x64) DLLs to file,
using the UAC save
AppDataLocalYourAppDependenciesx64 or x86 folders
Finally, call the Kernel32 LoadLibrary
function via P/Invoke on the dependencies.
IMPORTANT! Only ever load x86
unmanaged DLLs when the Environment.Is64BitProcess
flag is false. Vice versa for x64 unmanaged
Finally, sip margarita and watch your SharpDX
application in all its glory on a machine with no
DirectX Runtime installed!
EDIT 2: The above breaks the licensing
agreement for the DirectX Runtime
As Xoof points out in the comments, the above
breaks the licensing agreement for the DirectX
Runtime. Good he let us know really as I was about
to package these DLLs into commercial software.
Instead, we're going to go down the route of
pre-packaging a subset of the *cab files found
under C:Program Files (x86)Microsoft DirectX SDK
(June 2010)Redist with our installer. We will use
this to create our own mini DirectX Runtime (about
4.7MBytes) with just the files we need.
Hopefully the above info is useful to anyone
who wants to know how to dynamically load
platform-specific unmanaged DLLs with a managed
application, and how to pre-package a subset of
DirectX DLLs with your application!