#1246 Configuring triggers doesn't work on Mono

KeePass_2.x
closed
nobody
None
5
2015-02-11
2014-05-26
Ari Pollak
No

I'm currently using KeePass2 2.26 on Debian with Mono 3.0.6. So far everything works great, except that I get a crash when trying to create triggers. I go to Tools -> Triggers, click Add, click the Actions tab, click Add, then when I click on the grey box next to File/URL, the keepass window goes away and I get the following message in the console:

~~~~~~
System.ObjectDisposedException: The object was used after being disposed.
at System.Windows.Forms.Control.CreateHandle () [0x00000] in <filename unknown="">:0
at System.Windows.Forms.TextBoxBase.CreateHandle () [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.CreateControl () [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.SetVisibleCore (Boolean value) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.set_Visible (Boolean value) [0x00000] in <filename unknown="">:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:set_Visible (bool)
at System.Windows.Forms.DataGridView.BeginEdit (Boolean selectAll) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore (Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.DataGridView.OnMouseDown (System.Windows.Forms.MouseEventArgs e) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.WmLButtonDown (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.DataGridView.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00000] in <filename unknown="">:0
~~~~~~~

Discussion

  • Dominik Reichl

    Dominik Reichl - 2014-05-26
    • status: open --> closed
     
  • Ari Pollak

    Ari Pollak - 2014-05-26

    Ah, okay. I wish there were a better workaround, but for now I can at least edit the parameters in KeePass.config.xml manually once I add the trigger entries.

     
  • Paul Jackson

    Paul Jackson - 2014-08-14

    That bug has been a "lowest" priority bug in Mono for over a year, with no sign of work being done on it yet ... sad :).

    I have managed to add the trigger I wanted (to backup my keepass data when I save it), but I have no idea how to edit the XML to specify the action (run a shell script that does this ... I am on Ubuntu 14.04).

    If the shell script were for example "/home/paul/backup_keepass", then what changes would I make to the action for this trigger, which currently shows:

      <Actions>
        <Action>
          <TypeGuid>2uX4OwcwTBOe7y66y27kxw==</TypeGuid>
          <Parameters>
            <Parameter />
            <Parameter />
            <Parameter>True</Parameter>
          </Parameters>
        </Action>
      </Actions>
    
     
  • Paul

    Paul - 2014-08-14

    I've modified your trigger to match your request, hopefully. I've used the event "Saved database file", called it "Backup Database on Save" and added arguments to your script which can be replaced by an empty Parameter place holder.

    cheers, Paul

    <?xml version="1.0" encoding="utf-8"?>
    <TriggerCollection xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Triggers>
            <Trigger>
                <Guid>jKC5TuQQPkqruVHwxHuYaA==</Guid>
                <Name>Backup Database on Save</Name>
                <Events>
                    <Event>
                        <TypeGuid>s6j9/ngTSmqcXdW6hDqbjg==</TypeGuid>
                        <Parameters>
                            <Parameter>0</Parameter>
                            <Parameter />
                        </Parameters>
                    </Event>
                </Events>
                <Conditions />
                <Actions>
                    <Action>
                        <TypeGuid>2uX4OwcwTBOe7y66y27kxw==</TypeGuid>
                        <Parameters>
                            <Parameter>/home/paul/backup_keepass</Parameter>
                            <Parameter>Arguments if required</Parameter>
                            <Parameter>True</Parameter>
                        </Parameters>
                    </Action>
                </Actions>
            </Trigger>
        </Triggers>
    </TriggerCollection>
    
     
  • Paul Jackson

    Paul Jackson - 2014-08-14

    I've modified your trigger to match your request, hopefully.

    Thanks. That helped. I didn't require any arguments, and I couldn't see why I would need to pass a final parameter of True, so I reduced the <Parameters> to just:

    <Parameters>
        <Parameter>/home/paul/backup_keepass</Parameter>
    </Parameters>
    

    Perhaps I messed something up by doing this. For now, just invoking keepass2, entering my Master Password, and then selecting "Exit" from the "File" pull down menu (having done nothing useful ... just fire it up and exit immediately) results in an exception:

    Unhandled Exception:
    System.NullReferenceException: Object reference not set to an instance of an object
      at System.Windows.Forms.XplatUIX11.DestroyOffscreenDrawable (System.Object offscreen_drawable) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.XplatUI.DestroyOffscreenDrawable (System.Object offscreen_drawable) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control+DoubleBuffer.Dispose () [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.DisposeBackBuffer () [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.OnSizeChanged (System.EventArgs e) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.UpdateBounds (Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.UpdateBounds (Int32 x, Int32 y, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.SetBoundsCoreInternal (Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.SetBoundsCore (Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.ToolStrip.SetBoundsCore (Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.ToolStripDropDown.SetBoundsCore (Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.SetBoundsInternal (Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.SetBounds (Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.set_Size (Size value) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.ToolStripDropDownMenu.OnLayout (System.Windows.Forms.LayoutEventArgs e) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.PerformLayout (System.Windows.Forms.Control affectedControl, System.String affectedProperty) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.Control.PerformLayout () [0x00000] in <filename unknown>:0 
      at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:PerformLayout ()
      at System.Windows.Forms.ToolStripItem.OnParentChanged (System.Windows.Forms.ToolStrip oldParent, System.Windows.Forms.ToolStrip newParent) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.ToolStripItem.set_Parent (System.Windows.Forms.ToolStrip value) [0x00000] in <filename unknown>:0 
      at (wrapper remoting-invoke-with-check) System.Windows.Forms.ToolStripItem:set_Parent (System.Windows.Forms.ToolStrip)
      at System.Windows.Forms.ToolStripItemCollection.Remove (System.Windows.Forms.ToolStripItem value) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.ToolStripItem.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.ToolStripDropDownItem.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
      at System.Windows.Forms.ToolStripMenuItem.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
      at System.ComponentModel.Component.Finalize () [0x00000] in <filename unknown>:0
    
     
    Last edit: Paul Jackson 2014-08-14
  • Paul

    Paul - 2014-08-15

    Leave both parameters in and try again. The "True" parameter is to wait for exit. Set it to false if you don't want to wait.

     <Parameter>/home/paul/backup_keepass</Parameter>
     <Parameter />
     <Parameter>True</Parameter>
    

    cheers, Paul

     
    Last edit: Paul 2014-08-15
  • Paul Jackson

    Paul Jackson - 2014-08-16

    The other Paul suggested:

    Leave both parameters in and try again. The "True" parameter
    is to wait for exit. Set it to false if you don't want to wait.
    
         <Parameter>/home/paul/backup_keepass</Parameter>
         <Parameter />
         <Parameter>True</Parameter>
    

    Thanks for getting back to me. I tried both what you suggested above, with three Parameter arguments (the 2nd empty and the 3rd True), and also a variation with the 3rd Parameter set to False.

    I could see one difference between these two experiments. When the third parameter was True, there was a delay on exit, equal to the time my backup_keepass program requires to run. When the third parameter was False, there was no such delay, and the backup ran asynchronously. Given your explanation of the third parameter, this is exactly as expected.

    However, unfortunately, in either case, the program then crashed with the same Unhandled Exception as I recently reported above.

     
    Last edit: Paul Jackson 2014-08-16
  • Paul

    Paul - 2014-08-16

    Then set up a Cron job to run a script that checks if the database has been modified, if so run a backup.

    cheers, Paul

     
  • Paul Jackson

    Paul Jackson - 2014-08-16

    The other Paul wrote:

    Then set up a Cron job to run a script that checks if
    the database has been modified, if so run a backup.
    

    True - I can do that. Or I could use inotify (Linux), FileSystemWatcher, FindFirstChangeNotification or others (Windows), or fsevents (OS X).

    ===

    However, I will confess that I am finding it unfortunate that KeePass on Linux depends on the Linux port of Mono. I see from scanning this SourceForge bug database that the use of Mono results in quite a few unresolveable bugs in the KeePass port to Linux (such as this one). It also presents what seems to me to be a less than slick gui interface on Linux desktops, and it brings in a substantial stack of gui library that I otherwise had little use for.

    Granted, I am a long standing Linux (and Unix, since the days of getting 9-track tapes from Ken Thompson, back in the 1970's) expert, with an almost as long standing anti-DOS, anti-Windows, anti-Microsoft bias, so Mono would have a steep up hill climb to gain my support. If I were more expert in gui programming, and had more free time on my hands, I'd be tempted to try porting KeePass to a more Linux friendly and native graphical user interface ... but alas such is not the case.

    If someone does try such a port ... let me know and there's a fair chance I can be enticed to try it out.

    ===

    Thank-you, other Paul, for your responsive and supportive attention to this report.

     
  • T. Bug Reporter

    T. Bug Reporter - 2014-08-17

    porting KeePass to a more Linux friendly and native graphical user interface ...

    If someone does try such a port ... let me know and there's a fair chance I can be enticed to try it out.

    Isn't that what KeePassX was supposed to be?

     
    • Paul Jackson

      Paul Jackson - 2014-08-19

      T. Bug Reporter wrote:

      Isn't that what KeePassX was supposed to be?

      Indeed it is!

      I just now realized that there are quite a few alternative ports of KeePass to different operating environments, including KeePassX on Qt (for OS X and Linux), KeePassC on curses and Python, ... See http://en.wikipedia.org/wiki/KeePass for a list of such alternatives.

      Having realized this, I returned to this old bug, to suggest that died in the wool old Linux hackers like me would likely prefer Qt based KeePassX, or perhaps one of the other C, Perl or Python variants, over the Mono (.net) based KeePass, and found your note here.

      Good - thanks.

       
      Last edit: Paul Jackson 2014-08-19

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks