KeePass: Failed to Load the Specified File! Error Fix

Microsoft/Windows

I use KeePass to manage my personal passwords on my computer. I’ve used it without incident for quite a while, but that streak recently came to an end after having to completely reinstall Windows 8.1 after a hard drive failure (luckily I do manage backups of files).

After running Windows update, I received the following error from KeePass when attempting to open a KeePass database file:

<Database File Path Here>

Failed to load the specified file!

Common Language Runtime detected an invalid program.

The dialog that will appear should look similar to this:

KeePass: CLR Exception Message | Failed to load the specified file! Common Language Runtim detected an invalid program.

This error is annoying, because it is not exactly the most descriptive. However, there is a fairly easy to implement solution to this (albeit a little hacky). This solution is easier to implement if you run the portable versions of KeePass and have the .NET Framework version 2 installed on your system.

If you do not have the .NET Framework version 2 installed on your system, you can refer to the table in a previous article of mine Microsoft .NET Framework Download Locations. Once you have ensured you have version 2 installed on your system, continue with the rest of the article.

If you look at the directory containing KeePass.exe, you will find a file called KeePass.exe.config. This is a configuration file that is used by various systems on your computer, the details of which are not immediately important for this article. By default, the contents of this file should look like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.5" />
        <supportedRuntime version="v4.0" />
        <supportedRuntime version="v2.0.50727" />
    </startup>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="KeePass"
                    publicKeyToken="fed2ed7716aecf5c"
                    culture="neutral" />
                <bindingRedirect oldVersion="2.0.9.0-2.29.0.0"
                    newVersion="2.29.0.17893" />
            </dependentAssembly>
        </assemblyBinding>
        <enforceFIPSPolicy enabled="false" />
        <loadFromRemoteSources enabled="true" />
    </runtime>
    <appSettings>
        <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
    </appSettings>
</configuration>

What we are going to do is modify the configuration file to only look for the .NET Framework version 2. We can do this my removing the <supportedRuntime version="v4.5" /> and <supportedRuntime version="v4.0" /> lines from the element so that the new file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v2.0.50727" />
    </startup>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="KeePass"
                    publicKeyToken="fed2ed7716aecf5c"
                    culture="neutral" />
                <bindingRedirect oldVersion="2.0.9.0-2.29.0.0"
                    newVersion="2.29.0.17893" />
            </dependentAssembly>
        </assemblyBinding>
        <enforceFIPSPolicy enabled="false" />
        <loadFromRemoteSources enabled="true" />
    </runtime>
    <appSettings>
        <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
    </appSettings>
</configuration>

You should now be able to load your KeePass database files without issue.

Join the Discussion

Leave a comment

  • Tomahawk
    Tomahawk
    July 17, 2015 1:52 AM Reply

    I'm getting this error instead:

    "Failed to load the specified file!

    The file signature is invalid. Either the file isn't a Keepass database file at all or it is corrupted."

    I used the program yesterday, this happened when I started up my computer today after Windows installed updates. I hope the file isn't beyond repair, unfortunately I don't have an up to date backup. -Windows 8.1 64-bit, Keepass 2.29.

Subscribe to our newsletter