Menu

#1634 Cannot add Control to TabControl

KeePass_2.x
closed
nobody
multiple (1)
5
2017-09-13
2017-06-09
No

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).

System

  • Ubuntu 16.04 64-bit
  • KeePass 2.35
  • Mono 4.2.1

How to duplicate the error, and what happens

  1. Open one database.
  2. Open another database. Two tabs show.
  3. Click the first tab. The database correctly changes over to the first database, but the tabs disappear (although the display space for them remains).
  4. Change over to the second database using File > Open Recent. The error message appears, and KeePass hangs. I have to force-close KeePass.

The clipboard contents

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.

Related

Bugs: #1440
Bugs: #1566

Discussion

  • Paul

    Paul - 2017-06-09

    Please post your config file for us to test.

    cheers, Paul

     
  • Paddy Landau

    Paddy Landau - 2017-06-10

    Config file attached.

     
  • Paddy Landau

    Paddy Landau - 2017-06-20

    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 from

    m_tabMain.Height += 3;
    

    to

    m_tabMain.Height += 5;
    

    However, that figure didn't work for me. So, I followed the instructions in comment #5 but instead used

    m_tabMain.Height += 10;
    

    This completely solved the problem, and I can even use customised tab colours.

     
  • Dominik Reichl

    Dominik Reichl - 2017-08-28
    • status: open --> closed
     
  • Dominik Reichl

    Dominik Reichl - 2017-08-28

    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

     
    • Paddy Landau

      Paddy Landau - 2017-08-28

      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!

       
  • Paul

    Paul - 2017-08-29

    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

     
  • Dominik Reichl

    Dominik Reichl - 2017-08-29

    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

     
  • Paddy Landau

    Paddy Landau - 2017-08-30

    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.

     
  • Dominik Reichl

    Dominik Reichl - 2017-08-30

    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

     
    • Paddy Landau

      Paddy Landau - 2017-08-31

      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
  • Paddy Landau

    Paddy Landau - 2017-08-30

    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

     
  • Paul

    Paul - 2017-08-31

    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

     
    • Paddy Landau

      Paddy Landau - 2017-08-31

      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
  • Dominik Reichl

    Dominik Reichl - 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

     
    • Paddy Landau

      Paddy Landau - 2017-08-31

      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?

       
  • Dominik Reichl

    Dominik Reichl - 2017-09-01

    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

     
    • Paddy Landau

      Paddy Landau - 2017-09-02

      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.

       
    • Paddy Landau

      Paddy Landau - 2017-09-10

      Dominik, your modified version hangs every so often. Therefore, I'd like to follow your instructions for debugging it.

      1. As the problem doesn't occur with the stable 2.36 version, only with your modified version, where can I get your modified code, please?
      2. When I get the results, where should I report it? This thread doesn't seem to be the right place, as it's off-topic.

      Thank you.

       
  • Dominik Reichl

    Dominik Reichl - 2017-09-11

    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

     
  • Paddy Landau

    Paddy Landau - 2017-09-11

    Thanks, Dominik. I'm not able to test. Here is what I did.

    • Extract your ZIP file into a new folder.
    • Download and install MonoDevelop 7.1.
    • In MonoDevelop, open file KeePass.sln.
    • Select "Debug | x64" (I am running 64-bit Linux Lubuntu 16.04).
    • Build > Build KeePass (results in message "Build successful").
    • Run > Start Debugging.

    This leads to the error, "Build: 1 error, 0 warnings." The error shown reads:

    /app/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Error MSB4018: The "ResolveKeySource" task failed unexpectedly.
    This is an unhandled exception from a task -- PLEASE OPEN A BUG AGAINST THE TASK OWNER.
    System.NotSupportedException: Specified method is not supported.
      at System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject (System.Guid clsid, System.Guid riid) [0x00006] in /run/build/mono/mcs/class/referencesource/mscorlib/system/runtime/interopservices/runtimeenvironment.cs:204 
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /run/build/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305  (MSB4018) (KeePass)
    

    Unfortunately, I don't know Mono or MonoDevelop, and have absolutely no clue how to proceed. Are you able to help, please?

     
  • Dominik Reichl

    Dominik Reichl - 2017-09-11

    Did you run the PrepMonoDev.sh script after extracting the ZIP file?

    Best regards,
    Dominik

     
    • Paddy Landau

      Paddy Landau - 2017-09-12

      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?):

      System.IO.InotifyWatcher.ReadFromFD() in 
      System.IO.InotifyWatcher.Monitor() in /run/build/mono/mcs/class/System/System.IO/InotifyWatcher.cs:372
      System.Threading.ThreadHelper.ThreadStart_Context(System.Threading.ThreadHelper state) in /run/build/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:68
      System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Threading.ThreadHelper state, bool preserveSyncCtx) in /run/build/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957
      System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Threading.ThreadHelper state, bool preserveSyncCtx) in /run/build/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904
      System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Threading.ThreadHelper state) in /run/build/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:893
      System.Threading.ThreadHelper.ThreadStart() in /run/build/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:105
      

      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.

       
  • Dominik Reichl

    Dominik Reichl - 2017-09-13

    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

     

Log in to post a comment.