1
\$\begingroup\$

I have developed a windows application to read gamepad using SharpDx (XInput) and C# (VS 2008). The application is running smoothly in my development environment. But when i move to some other machine (Windows 7), its giving me error "Unable to load dll 'xinput1_3.dll' ". My question is is it mandatory to have directx runtime environment in clint machine also to run the exe ? Because i was thinking it will make use of dll "XInput9_1_0.dll" which is a part of windows 7.

\$\endgroup\$
1
  • \$\begingroup\$ I am seeing xinput9_1_9.dll in my windows/system32 folder. So i believe its part of windows 7. \$\endgroup\$
    – Naveen
    Commented Oct 8, 2013 at 12:03

3 Answers 3

2
\$\begingroup\$

Yes. SharpDX is simply a wrapper over the DirectX DLLs. The SharpDX files do not include the DirectX DLLs, and therefore you must redistribute them with your application if you want it to run on other computers.

Note that some DLLs are included in some versions of Windows, but apart from the very basic files, like d3d9.dll, you should not suppose that any DirectX DLLs are going to be available in the target computer. This is especially true for the newer DirectX components, such as XInput, XACT or XAudio2.

That said, simply copying the DLLs with your application won't work in most cases (the d3dx9 files being an important exception). DirectX components are based on COM, and therefore must be registered.

Microsoft recommends you use the redistributable package installer to install the DirectX components required by your application.

If you use this approach (which I recommend as well), you don't have to distribute every DirectX file. You just need to include:

  • dxsetup.exe
  • dsetup32.dll
  • dsetup.dll
  • dxupdate.cab

as well as the specific DLLs required by your application. These files can be found in Program Files\DirectX SDK\Redist\ if you have the DirectX SDK installed in your computer.

If you do this, you can then call dxsetup.exe (preferably with the /silent switch) to install the required DirectX components in the target computer.

This can all be automatically performed by a Visual Studio Setup project. You just have to include these files, and have dxsetup.exe /silent called from a custom action.

To test your setup, I recommend you setup a virtual machine (I prefer VirtualBox), save the disk image as soon as the base OS is installed, and try your installer. If you have a problem, you can revert to the freshly installed disk image, and try again with a new installer.

Note that since you're writing your program in C#, you also need the .NET framework to be installed in the target machine for your program to run. More information on how to do this can be found here.

\$\endgroup\$
0
1
\$\begingroup\$

This really depends on which DirectX SDK was used to build the binaries. If someone uses for example the SDK released in month X of year Y, you'll most likely also need the DirectX version that has been up to date at that time. Unfortunately Microsoft ditched most versioning stuff starting with DirectX 9.0c. There are tons and tons of hidden subversions, all being backwards compatible, but adding additional support libraries. In a similar way there are different "sub versions" of DirectX 10 and 11 as well.

Easiest way to ensure your programs works, would be either bundling (or providing a download URL) to Microsoft's DirectX Runtime Web Installer. It's essentially a downloader that will always install the correct and latest runtime files for the system it's run on.

\$\endgroup\$
5
  • \$\begingroup\$ So i have to have directX installed in target machine? I am not in a position to do that right now. Is there any other option? \$\endgroup\$
    – Naveen
    Commented Oct 8, 2013 at 9:51
  • \$\begingroup\$ Recompile with an older SDK version I guess. \$\endgroup\$
    – Mario
    Commented Oct 8, 2013 at 11:23
  • \$\begingroup\$ You mean the SharpDX? Because SharpDx is using xinput dll actually. \$\endgroup\$
    – Naveen
    Commented Oct 8, 2013 at 12:05
  • \$\begingroup\$ You must have the runtime available on the target machine, so you will need to package the runtime installer. It's not legal to distribute the DLLs directly, and recompiling SharpDX against an older SDK version is likely a lot of work (and you'll still need that completely runtime available). \$\endgroup\$
    – user1430
    Commented Oct 8, 2013 at 13:17
  • \$\begingroup\$ Yes, I'd be talking about SharpDX, but as Josh mentioned already, not really worth the trouble (there might also thinks that break or are impossible to do in older (sub) versions). Easiest way is to simply provide a download link to the runtime. \$\endgroup\$
    – Mario
    Commented Oct 9, 2013 at 9:58
0
\$\begingroup\$

The target machine is missing the .dll files, either you install the redistributable or just copy the needed .dll files to the executable folder. The first option is the one that most professional in my opinion.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Plus the second option is not allowed in most cases when considering Microsoft's licensing terms for runtime files. I'm not 100% sure about DirectX, but wouldn't expect any exception there. \$\endgroup\$
    – Mario
    Commented Oct 8, 2013 at 9:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .