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.

    John
    John
    July 17, 2015 4:56 PM Reply

    Hello Tomahawk, thanks for taking the time to leave a comment!

    I sympathize with not being able to load your KeePass database file. The error message you are getting is indicating that the file is invalid or corrupt. I am not sure about the process to recovering a corrupted KeePass file, and have been in the situation of not having any recent backups.

    However, here are a few things you can try:

    • You can always try to restore Windows to a point before your updates were installed. This article from Microsoft explains the process for Windows 8/8.1. The section "Restore your PC to an earlier point in time" is the relevant section here. If the corruption was caused by a Windows update, hopefully the file can be recovered from an earlier restore point and you can safely create a back up before installing the Windows updates again.
    • If you have File History setup and enabled in Windows you can always try restoring the file to an earlier version using the history.
    • Additionally, KeePass can try to repair the file using the File > Import option. I personally do not have much experience with this option.

    Hopefully one of these options will allow you to recover your KeePass database file. As for easily maintaining up-to-date backups in the future, I personally save my KeePass file in a folder that is synced with Dropbox. When I've had problems with corrupt files in the past, I was always able to restore the file to an earlier point using Dropbox's history. Admittedly, this won't help you out right now, but is definitely something to consider in the future!

    Best of luck, John

Subscribe to our newsletter