FF 72.0.2, KeePass 2.44, KeeFox 3.2.7 and RPC Plugin 1.10.0 cause KeePass to crash

Posted this under the plugin but it seems appropriate here as well.

KeePass starts up minimized to tray, but any hovering over it will cause it to crash. Ctrl Alt K does not work. It keeps crashing (exiting)

When Kee for FF is disabled as an addon, KeePass runs fine. When I run “C:\Program Files (x86)\KeePass Password Safe 2\KeePass.exe” --KPRPCDebug=c:\temp\kprpc-debug.log I get this:

Logger initialised.
Client managers started.
RPC service started.
Starting KPRPCServer
Fleck says: Constructed server at ws://localhost:12546. Explicit port: 8181. Implicit port: 12546. Loopback only? True
Fleck says: Starting server at ws://localhost:12546. Loopback only? True
Fleck says: Server started at ws://localhost:12546
Started KPRPCServer
RPC server started.
KPRPC startup failed: System.BadImageFormatException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The module was expected to contain an assembly manifest.
File name: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at KeePassRPC.DPIScaledToolStripMenuItem..ctor(String text)
   at KeePassRPC.KeePassRPCExt.Initialize(IPluginHost host)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Fleck says: Client connected from 127.0.0.1:51110
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51111
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51112
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51113
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51114
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51115
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51116
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51117
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51118
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51119
Fleck says: 243 bytes read
Fleck says: Error while reading. Exception: Fleck2.WebSocketException: Exception of type 'Fleck2.WebSocketException' was thrown.
   at Fleck2.HandlerFactory.BuildHandler(WebSocketHttpRequest request, Action`1 onMessage, Action onClose, Action`1 onBinary)
   at Fleck2.WebSocketConnection.CreateHandler(IEnumerable`1 data)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )
Fleck says: Client connected from 127.0.0.1:51120
Fleck says: 495 bytes read
Fleck says: Building Hybi-14 Response
Fleck says: Sent 129 bytes
Fleck says: 608 bytes read
Fleck says: Client connected from 127.0.0.1:51109
Fleck says: Application Error. Exception: System.BadImageFormatException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The module was expected to contain an assembly manifest.
File name: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at Jayrock.Json.Conversion.Converters.ExpandoObjectExporter..ctor()
   at Jayrock.Json.Conversion.ExportContext.get_StockExporters()
   at Jayrock.Json.Conversion.ExportContext.FindExporter(Type type)
   at Jayrock.Json.Conversion.ExportContext.Export(Object value, JsonWriter writer)
   at Jayrock.Json.Conversion.JsonConvert.ExportToString(Object value)
   at KeePassRPC.KeePassRPCClientConnection.AbortWithMessageToClient(KPRPCMessage data2client)
   at KeePassRPC.KeePassRPCExt.MessageRPCClientConnection(IWebSocketConnection webSocket, String message, KeePassRPCService service)
   at Fleck2.Handlers.Hybi13Handler.<>c__DisplayClassa.<Create>b__6(FrameType op, Byte[] data)
   at Fleck2.Handlers.Hybi13Handler.ReceiveData(List`1 data, ReadState readState, Action`2 processFrame)
   at Fleck2.WebSocketConnection.<>c__DisplayClassb.<Read>b__a(Int32 r)
   at Fleck2.SocketResult.Success[TResult](Action`1 callback)
   at Fleck2.SocketWrapper.<>c__DisplayClass7.<Receive>b__6(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Fleck says: Sent 4 bytes
Fleck says: Failed to send. Disconnecting.. Exception: System.InvalidOperationException: This operation has already had OperationCompleted called on it and further calls are illegal.
   at System.ComponentModel.AsyncOperation.VerifyNotCompleted()
   at System.ComponentModel.AsyncOperation.Post(SendOrPostCallback d, Object arg)
   at KeePassRPC.KeePassRPCClientConnection.ShuttingDown()
   at KeePassRPC.KeePassRPCClientManager.RemoveRPCClientConnection(KeePassRPCClientConnection client)
   at KeePassRPC.KeePassRPCExt.RemoveRPCClientConnection(IWebSocketConnection webSocket)
   at Fleck2.WebSocketConnection.CloseSocket()
   at Fleck2.WebSocketConnection.<>c__DisplayClassf.<SendBytes>b__d()
   at Fleck2.SocketResult.Success(Action callback)
   at Fleck2.SocketWrapper.<>c__DisplayClassf.<Send>b__e(SocketResult result)
   at Fleck2.SocketFactory.<>c__DisplayClass16.<DoAsyncTask>b__15(Object )

BadImageFormatException usually indicates a mismatch between a 64bit and 32bit application component. Not sure about the system tray interaction though. I don’t have a windows machine available right now but would be interesting to know if the problem is limited to just this hovering on the system tray when starting minimised or if different KeePass configurations can trigger the issue.

Has it ever worked for you? If so, what changed?

Seeing the crash in the DPIScaledToolStripMenuItem class might indicate that there is something unusual about the DPI settings on your system which is triggering a bug that no-one else has found; or it could just be coincidence.

Yes, it worked for me for the last 8 years. I suppose what changed was the newest Firefox? I’m really unsure since things update in the background often - but I’ve tried downgrading to Keepass 2.4.3 with no luck.

Its not just the tray - it basically crashes immediately when Kee addon (in FF) is enabled… When Kee is disabled, it works fine. Any suggestions on what to do? This is really killing my workflow.

EDIT I also tried with a brand new install of FF with no other addons than Kee. Same issue: KeePass works great with the RPC plugin installed… The second you enable Kee, KeePass crashes; the second you disable it it works flawlessly again.

FWIW, I ran KeePass with the debug command and then enabled Kee; it crashed instantly and nothing was written to the log, so maybe the DPI piece is a red herring.

Another contender for automatic updates breaking things is Windows updates. Since the error is thrown when KeePass tries to access the System.Core assembly, this may indicate that your windows installation has become corrupted, or at least your .NET Framework installation.

I tried reinstalling .NET and same issue. Is there any better way to debug this, especially what happens at the point of enabling Kee from the FF Addons panel? The log is not being written to at this time as it instantly quits without a dialog or warning.

Update for anyone else experiencing this: I had to reinstall Win10 and now it works. Sucks to reinstall a whole operating system just for this feature but I suspect other things were corrupted as well.