Closing Form using ActiveWindow.Close() - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Closing Form using ActiveWindow.Close()

Last post 10-29-2015 02:55 AM by mexicanikey. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-17-2005 07:16 PM

    Closing Form using ActiveWindow.Close()

    I'm wondering if anyone else has encountered an issue with closing forms using C# and thisApplication.ActiveWindow.Close() in particular:

    My form submits data to a K2 web service and, upon successful submission, displays a dialog box and then exits InfoPath using thisApplication.ActiveWindow.Close().

    Unfortunately, if a user decides to change the focus to a different window during the form submission, the dialog box is displayed fine but the InfoPath form doesn't close and instead a "Object reference not set to an instance of an object" exception is raised.

    Any thoughts as to what is causing the problem? Is it an issue with the web service I'm calling or the window that I'm trying to close?

    I've tried to regain the focus by using thisApplication.ActiveWindow.Activate() prior to calling Close() but to no avail.

    Thanks in advance,
    David.
  • 11-17-2005 07:26 PM In reply to

    Re: Closing Form using ActiveWindow.Close()

    BTW, it's definitely the thisApplication.ActiveWindow.Close() code that is causing the exception.

    I've wrapped the code in a try...catch section and can at least trap the error.
  • 11-17-2005 07:44 PM In reply to

    Re: Closing Form using ActiveWindow.Close()

    Hi David,

    Did you try:
    thisApplication.ActiveWindow.Close(true);


    Regards,

    Franck Dauché
    InfoPathDev
  • 11-17-2005 08:03 PM In reply to

    Re: Closing Form using ActiveWindow.Close()

    Thanks Franck. My apologies for not being clear, when I try to close the form I am using:

    thisApplication.ActiveWindow.Close(true);

    It works fine when InfoPath has focus, but fails when another window has focus.

  • 11-17-2005 10:35 PM In reply to

    Re: Closing Form using ActiveWindow.Close()

    Hi David,

    Did you try: thisXDocument.View.Window.Close(true); just for the sake of it?

    Regards,

    Franck Dauché
    InfoPathDev
  • 10-29-2015 02:55 AM In reply to

    Re: Closing Form using ActiveWindow.Close()

    Good day. Need help! How to close form infopath correctly? I have same problem as author (i call web service, show message to user, than close infopath and receive exception) I close infopath like this: thisApplication.ActiveWindow.Close(true) And exception follows: Value cannot be null. Parameter name: key at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Collections.Generic.Dictionary'2Insert(TKey key, TValue value) at System.Collections.Generic.Dictionary'2set_Item(TKey key, TValue value) at Microsoft.Office.InfoPath.Internal.ObjectIdentityHash.Create[T](Object internalObject, CreateOMObject createOMObject) at Microsoft.Office.InfoPath.Internal.WindowHost.Create(WindowObject window) at Microsoft.Office.InfoPath.Internal.ApplicationHost.get_ActiveWindow() at MyForm.FormCode.CloseForm() I only found one page in google about this exception, http://sharepoint-infopath.blogspot.ru/2011/11/infopath.html but it is not helpfull Thankx!
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.