1

I'm trying to build a game using Monogame. Monogame uses its own bunch of DLLs. However inside one of those DLLs is a dependency on another DLL (which could potentially not exist as it was not installed).

More specifically when trying to utilize a method/class of Monogame's DLLs

GamePad.GetState(PlayerIndex.One).Buttons.Back

This error is produced:

Unable to load DLL 'xinput1_3.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The fix for this error isn't difficult. The user needs to install the correct system requirements.

How do I tell this to the user from the front end? My aim is to inform the user that 'Gamepad controllers are disabled for this because xxx is not installed on your system', while carrying on running the game - as gamepads are optional.

Is there a way I could have caught this issue (i.e. is there a way I could have checked to see if this DLL exists - without being very specific of its location/filepath) before attempting to utilize the method/class?

Is having a try-catch block around the whole application the best approach?

Are there better ways to handling the (common?) 'Unable to load DLL' cases?

My main goal is to ignore any DLL dependency issues as I plan to distribute this game without installers. Plus any missing non-game-breaking DLLs should just be ignored.

Serge P
  • 1,591
  • 8
  • 22
  • 42
  • 1
    Why burden the user with something you should arguably be doing? That's what installers are for. XNA games on Steam install both XNA and .NET runtimes –  Feb 04 '16 at 03:06
  • I just read that you plan to distribute without installers and how you intend to ignore decency errors. Considering the type of your application, I think that's somewhat neglectful and disrespectful to your user base –  Feb 04 '16 at 03:15
  • Completely agree with you. This is especially important when it comes to publishing on official stores like Steam. My reason for a single on-the-go executable that doesn't require (tedious?) installations is just a personal preference. – Serge P Feb 04 '16 at 03:38
  • (when I said _"ignore decency errors"_ it should have read "ignore **dependency** errors") - damn you iPhone ;) –  Feb 04 '16 at 10:22

2 Answers2

0

One solution could be to programmatically check all system folders for the required dlls during startup and alert user if they are missing.

EDIT: There is a better solution, check using LoadLibrary() function, Check if a DLL is present in the system

Community
  • 1
  • 1
Nemo
  • 3,285
  • 1
  • 28
  • 22
0

You can check list of all .DLLs you need before running the app. Of course you can alays rely on try and catch for DLLs which you never knew.

Pushpendra
  • 820
  • 7
  • 11