July 5, 2015 —John Koster
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:
1<Database File Path Here>2 3Failed to load the specified file!4 5Common Language Runtime detected an invalid program.
The dialog that will appear should look similar to this:
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:
1<?xml version="1.0" encoding="utf-8" ?> 2<configuration> 3 <startup> 4 <supportedRuntime version="v4.5" /> 5 <supportedRuntime version="v4.0" /> 6 <supportedRuntime version="v2.0.50727" /> 7 </startup> 8 <runtime> 9 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">10 <dependentAssembly>11 <assemblyIdentity name="KeePass"12 publicKeyToken="fed2ed7716aecf5c"13 culture="neutral" />14 <bindingRedirect oldVersion="2.0.9.0-2.29.0.0"15 newVersion="2.29.0.17893" />16 </dependentAssembly>17 </assemblyBinding>18 <enforceFIPSPolicy enabled="false" />19 <loadFromRemoteSources enabled="true" />20 </runtime>21 <appSettings>22 <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />23 </appSettings>24</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
1<?xml version="1.0" encoding="utf-8" ?> 2<configuration> 3 <startup> 4 <supportedRuntime version="v2.0.50727" /> 5 </startup> 6 <runtime> 7 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 8 <dependentAssembly> 9 <assemblyIdentity name="KeePass"10 publicKeyToken="fed2ed7716aecf5c"11 culture="neutral" />12 <bindingRedirect oldVersion="2.0.9.0-2.29.0.0"13 newVersion="2.29.0.17893" />14 </dependentAssembly>15 </assemblyBinding>16 <enforceFIPSPolicy enabled="false" />17 <loadFromRemoteSources enabled="true" />18 </runtime>19 <appSettings>20 <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />21 </appSettings>22</configuration>
You should now be able to load your KeePass database files without issue.
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.