none
Modal vs Modeless RRS feed

  • Question

  • We have an add-in for Outlook that has been working properly for years. With the installing of update KB 2794707, we've run into a strange error.

    If we call our new Outlook window in a modal format, we have no issues. All works as it always did. When we call our window in a modeless format, we receive a trigger to save the form, which causes errors. Has anyone else seen anything similar to this? Any ideas what can be done, or what parameters may have changed in the calling of the display method?

    In the meantime, I'll continue searching through the forums. Thanks!

    Tuesday, November 26, 2013 4:08 PM

All replies

  • >"we receive a trigger to save the form, which causes errors."

    Can you be more specific than that?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, November 26, 2013 4:24 PM
  • I wish I could.

    Here is the general sequence of events:

    We create parameters that allow our custom form to tie into our database, and create the form using VSTO. We then call the display(false) method on the outlook object. Once that method is called, we then populate the various links our form requires.

    When we call display(true), we transition through from loading, linking, and ready just fine. When we call display(false), we transition from loading to saving (which throws an error) to linking and then ready.

    Even though this error is thrown, if we simply catch it and write it to a log, all works fine. It appears cosmetic in nature, as everything else does as it should. Just catching the error and eating it isn't acceptable though, we'd really like to have a better idea of why this behavior has changed so we can stave off any future issues.

    Again, before we installed this update, there was no change from loading to saving... it simply ran through the process to build the links needed for our form. What is causing this trigger is a mystery to me, and why it would happen when creating a form modeless and not modal is past me.

    Thanks again!

    Tuesday, November 26, 2013 4:33 PM
  • So you don't have any details about the error that you catch and the line of your code that raises it? How is that possible?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, November 26, 2013 4:35 PM
  • What I'm catching is a transition error from loading to ModifyExclusive, and that is coded as an unacceptable transition.
    Tuesday, November 26, 2013 4:38 PM
  • What is the *exact* exception?

    Which line of your code raises it?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, November 26, 2013 4:47 PM
  •         public bool AcceptsTransition(StateEnum target, bool requestLock)
            {
                // Check if the Object has been disposed
                AssertNotDisposed();

                // Declare Locals
                bool succeed = false; // Controls whether to proceed with the transition or not

                try
                {
                    // Begin Critical Section
                    MachineLock.AcquireReaderLock(Timeout.Infinite);

                    // Declare Locals
                    bool acceptableTransition = AcceptsTransitionLockless(target);
                    bool transitionSelf = m_current.Identifier.Equals(target); // are we transitioning to self?
                    bool acceptsConcurrentLocks = m_current.AcceptConcurrentLocks;
                    bool locked = m_current.Locked;

                    // Is this an acceptable transition?
                    if (acceptableTransition)
                    {
                        // Is it locked?
                        //  is it a selftransition? do we allow concurrent locks? are we requesting a lock?
                        // Else
                        //  succeed, since it is not locked, and it is an acceptable transition

                        // Is the state already locked?
                        if (locked)
                        {
                            // Is this a Self Transition, are we requesting a lock, and do we allow Concurrent Locks?
                            if (transitionSelf)
                            {
                                // Are we requesting a lock? If so, need to check if concurrent locks are permitted
                                if (requestLock)
                                {
                                    // Request Lock & Allow Concurrent Lock == Succeed
                                    if (acceptsConcurrentLocks)
                                    {
                                        succeed = true;
                                    }
                                    // Request Lock, but don't permit concurrent locks == Fail
                                    //else
                                    //{
                                    //}
                                }
                                // Transition to self and doesn't request locks == Succeed
                                else
                                {
                                    succeed = true;
                                }
                            }
                            // Locked and is not a Self Transition == Fail
                            //else
                            //{
                            //}
                        }
                        // The state is not Locked and is an Acceptable Transition == Succeed
                        else
                        {
                            succeed = true;
                        }
                    }
                    // This is not acceptable transition == Fail
                    //else
                    //{
                    //}
                }
                catch(Exception error)
                {
                    LogManager.LogErrorStatic(this, "AcceptsTransition(StateEnum target, bool requestLock)", "Failed to query Accepts Transition", error);
                }
                finally
                {
                    // End Critical Section
                    MachineLock.ReleaseReaderLock();
                }

                return succeed;
            }

    AcceptsTransitionLockless is here:

            private bool AcceptsTransitionLockless(StateEnum target)
            {
                // Check if the Object has been disposed
                AssertNotDisposed();

                try
                {
                    // Begin Critical Section
                    MachineLock.AcquireReaderLock(Timeout.Infinite);

                    return m_current.AcceptsTransition(target);
                }
                finally
                {
                    // End Critical Section
                    MachineLock.ReleaseReaderLock();
                }
            }

    The exception is a NewInvalidStateException.

    Tuesday, November 26, 2013 4:57 PM
  • Oh, and the AcceptsTransition:

            public override bool AcceptsTransition(CrmItemOperationStates state)
            {
                switch (state)
                {
                    case CrmItemOperationStates.Loading:
                        return true;
                }

                return false;
            }

    Tuesday, November 26, 2013 5:25 PM
  • ModifyExclusive is the (state) that's being passed.
    Tuesday, November 26, 2013 5:26 PM
  • Frankly speaking, I have no idea what this code does.

    What kind of transition is this? From what to what? What does it have to do with Outlook?

    When is this code invoke? Is there a particular Outlook event that yo uare triggering?

    When you show the form in Outlook, what is its parent?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, November 26, 2013 6:12 PM
  • This code is invoked after the command to display the item. There is a transition to modifyExclusive called when the data is saved. There is no reason for this to save as yet, and this call was not made in outlook 2007 or 2010 until this latest update. This is why I was asking if there was a change in the display() method in the outlook OOM.

    When displaying the outlook item in a model fashion, i.e. display(true) then there is no call to save the data. When the call to display the item, modal or modaless without the security patch installed, there is no call to save the data. Something is kicking back to the item, and I have no clue what it is or where it's coming from. I'm sorry I can't be more clear. Believe me, it's driving me batty.

    Tuesday, November 26, 2013 6:29 PM