Cannot add Control to TabControl
A lightweight and easy-to-use password manager
Brought to you by:
dreichl
Reference bugs [#1440] and [#1566].
I get the following error when I open two databases at the same time. If I'm always sure to close one before opening the other, I don't get an error (but it's terribly inconvenient).
A fatal error has occurred!
An extended error report has been copied to the clipboard.
Cannot add Control to TabControl. Only TabPages can be directly added to TabControls.
I have removed all plugins.
I also removed all custom colours from the database (I don't have custom colours for the UI).
Cannot add Control to TabControl. Only TabPages can be directly added to TabControls. System.Windows.Forms at System.Windows.Forms.TabControl+ControlCollection.Add (System.Windows.Forms.Control value) <0x414b0000 + 0x00277> in <filename unknown>:0 at System.Windows.Forms.Control.set_Parent (System.Windows.Forms.Control value) <0x415513e0 + 0x0007e> in <filename unknown>:0 at System.Windows.Forms.Control..ctor (System.Windows.Forms.Control parent, System.String text) <0x41551390 + 0x0003b> in <filename unknown>:0 at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor (System.Windows.Forms.Control,string) at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) <0x413102c0 + 0x0099b> in <filename unknown>:0 at System.Windows.Forms.XplatUIX11.DispatchMessage (System.Windows.Forms.MSG& msg) <0x414623f0 + 0x0001f> in <filename unknown>:0 at System.Windows.Forms.XplatUI.DispatchMessage (System.Windows.Forms.MSG& msg) <0x414623c0 + 0x0001f> in <filename unknown>:0 at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) <0x4139f8c0 + 0x00d03> in <filename unknown>:0 at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) <0x4139f810 + 0x00057> in <filename unknown>:0 at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) <0x4139f500 + 0x00033> in <filename unknown>:0 at KeePass.Program.Main (System.String[] args) <0x412626c0 + 0x00d1b> in <filename unknown>:0 Void Add(System.Windows.Forms.Control)
Thank you.
Please post your config file for us to test.
cheers, Paul
Config file attached.
I already posted but it seems to have disappeared; apologies if this results in a double-post.
I found a solution. It is an amendment of comment #5 in Launchpad bug891029; also see comment #18.
The original solution was to change a line in
Forms/MainForm.cs
fromto
However, that figure didn't work for me. So, I followed the instructions in comment #5 but instead used
This completely solved the problem, and I can even use customised tab colours.
Increasing the tab bar height more and more doesn't look like a reasonable workaround to me. Apart from the fact that it's unclear why this workaround works at all, the height cannot be increased indefinitely, and even adding 5 to the height results in a rather ugly user interface.
I've now added a different workaround: KeePass now checks whether it's running under Mono and if so, it doesn't show images on tabs anymore. Although I wasn't able to reproduce the issue under Ubuntu 16.04, I was able to reproduce a related issue under Kubuntu 17.04, and the new workaround fixes it.
Here's the latest development snapshot for testing:
http://keepass.info/filepool/KeePass_170828.zip
Thanks and best regards,
Dominik
Thank you for the fix, Dominik.
Interestingly, I had no change in the UI when I increased the tab height, so for me there was no aesthetic concern. Perhaps that is a hint to the problem: maybe in some distributions, the height simply isn't enough to display the tab?
I wasn't sure what to do with the contents of your ZIP file, so I simply copied the three files to /usr/lib/keepass2, overwriting the two files that already existed (file KeePass.XmlSerializers.dll was new). Of course, I restarted KeePass2 after doing this.
Assuming that what I did was correct, I can confirm that the fix has worked.
I imagine that the PPA will be updated in due course. In the meantime, I shall continue to use your fix.
Thank you for your time and effort!
The method you used to update the files is correct.
The PPA will be updated after a new KeePass is released and the PPA maintainer gets around to it - could be a while.
cheers, Paul
Glad to hear it works for you, too. Thanks for testing it.
If you want to test KeePass development snapshots in the future: it is sufficient to extract the ZIP to a new folder and run KeePass.exe (under Linux via '
mono KeePass.exe
'); no need to overwrite your stable version.Best regards,
Dominik
Bad news. The hanging bug appears to have resurfaced with a vengeance in this fix. The workaround that I mentioned in comment #7 of that bug unfortunately doesn't work.
I have had to revert to the official version from the PPA.
I don't have time to test anything now, but if you have any ideas, I shall be happy to try them later.
I don't see how any of the changes since 2.36 could cause a hang. Maybe you can get the KeePass 2.36 source code, run the 'PrepMonoDev.sh' script (in the 'Build' folder), open the solution in MonoDevelop, build and run KeePass in debug mode, break and post the stack trace when the hang occurs?
Best regards,
Dominik
Dominik, I had another hang, unfortunately. I have
mono-devel
installed, but absolutely no idea how to use it.I fetched the KeePass 2.36 source code and ran
PrepMonoDev.sh
.Now, how do I "open the solution in MonoDevelop, build and run KeePass in debug mode, break" and find the stack trace when the hang occurs? Sorry, I'm not a developer so I don't know how to do any of that.
Last edit: Paddy Landau 2017-08-31
Interesting. I looked at
KeePass.config.xml
and saw that the file URLs were either weird or invalid. For example, what should have been:/home/paddy/Documents/…
was instead:
../../home/paddy/Documents/…
I fixed all of them to their canonical forms, restarted the computer (when KeePass acts up, I find that the computer requires a restart before KeePass will work again — perhaps a bug in mono?), and so far KeePass seems to be working correctly.
May I suggest that whenever you save the file URLs, you save the canonical form? In Linux, you can obtain the canonical from from any valid file URL with the
readlink
function.readlink 1
readlink 2
The URLs are always saved relative to KeePass so installation on another device will find the database if the drive letter changes. They will be re-written everytime you close KeePass.
cheers, Paul
Thanks, Paul, but the concept of a drive letter doesn't apply in Linux. In my case, I had moved neither the databases nor the installation, so there was no apparent reason for the invalid paths.
I have made changes to the KeePass database, saved them, and closed KeePass, and yet the paths were not updated in the file
KeePass.config.xml
(they are still set as I corrected them). So, maybe they are rewritten only in Windows but not Linux?EDIT: I've changed and saved the database, and closed and reopened KeePass2, three or four times, and
KeePass.config.xml
remains unchanged; indeed, its last-modified date is still set to yesterday when I corrected the paths.Last edit: Paddy Landau 2017-08-31
I don't see any problem with the relative paths.
On the hang: run MonoDevelop, open the 'KeePass.sln' file, make sure the 'Debug' configuration is active, build and run the 'KeePass' project. When KeePass hangs, switch to MonoDevelop and break the execution. You should then see a stack trace, which might indicate what KeePass is doing while it apparently hangs.
Best regards,
Dominik
Thanks, Dominik.
I shall try the Mono Develop as you suggest. However, the current released app doesn't hang for me (only your new modified version does), so I think that I should I do it with your modified source code. Where can I find it?
Just try it with the KeePass 2.36 source code. Like I wrote, there shouldn't be any changes since then that could result in a hang.
Best regards,
Dominik
Thanks, Dominik, but the current stable version hasn't hung for me. At the moment, since I last posted, your changed version has been behaving itself. So, I'll wait until the PPA is updated (presumably to version 2.37), and then, if it happens again, I'll do as you suggest.
Thanks again.
Dominik, your modified version hangs every so often. Therefore, I'd like to follow your instructions for debugging it.
Thank you.
This is very mysterious; from a hanging point of view there shouldn't be any difference between 2.36 and the latest development snapshot.
Anyway, here's the latest source code:
http://keepass.info/filepool/KeePass_170911_Src.zip
You can post the results here or in the forums.
Thanks and best regards,
Dominik
Thanks, Dominik. I'm not able to test. Here is what I did.
This leads to the error, "Build: 1 error, 0 warnings." The error shown reads:
Unfortunately, I don't know Mono or MonoDevelop, and have absolutely no clue how to proceed. Are you able to help, please?
Did you run the
PrepMonoDev.sh
script after extracting the ZIP file?Best regards,
Dominik
Now, I feel silly! Yes, you're right, I did forget to do that.
Here are the intermediate results.
There is a warning for you on line 114:
/home/paddy/Downloads/NoBackup/KeePass_170911_Src/KeePassLib/Serialization/KdbxFile.Read.Streamed.cs(4,4): Warning CS0618: 'XmlReaderSettings.ProhibitDtd' is obsolete: 'Use DtdProcessing property instead' (CS0618) (KeePass)
When I start KeePass2 from MonoDevelop (in debug mode), it works without any plugins; and with the QuickUnlock plugin. But when I include the
keepass2-plugin-tray-icon
(for Lubuntu), it hangs on startup. When this happens, one of my CPU cores hits 100% and another hits 80%, and it sits there churning over at 100%+80% until I Run > Stop and exit MonoDevelop. Anyway, I went to MonoDevelop to break the execution (as you said to do), but I couldn't figure out the right way to do this. What I did was to choose Run > Pause. Here is one of the results from the "Call Stac" (I presume that this is meant to be "Call Stack", and is the stack trace?):I hope that this is of some help. I don't know why it hits 100% + 80% with the
keepass2-plugin-tray-icon
, because that plugin works just fine when I run KeePass2 normally.The first issue is expected and can be ignored. In order to avoid confusion in the future, I've now enhanced the PrepMonoDev.sh script to upgrade the DTD processing definition, such that this warning doesn't occur anymore.
I can't reproduce the second issue; this plugin problem may be dependent on the operating system, and I doubt I can do anything in KeePass against it. Please test without any plugins.
I indeed meant to "pause" the execution, sorry (in Visual Studio it's called "Break", whereas MonoDevelop calls it "Pause").
Thanks and best regards,
Dominik