<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Closing Form using ActiveWindow.Close()</title><link>https://www.infopathdev.com:443/forums/thread/104504.aspx</link><pubDate>Thu, 29 Oct 2015 09:55:42 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:104504</guid><dc:creator>mexicanikey</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/104504.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=104504</wfw:commentRss><description>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&amp;#39;2Insert(TKey key, TValue value)
at System.Collections.Generic.Dictionary&amp;#39;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!</description></item><item><title>Re: Closing Form using ActiveWindow.Close()</title><link>https://www.infopathdev.com:443/forums/thread/14022.aspx</link><pubDate>Fri, 18 Nov 2005 06:35:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14022</guid><dc:creator>franck</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14022.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14022</wfw:commentRss><description>Hi David,&lt;br /&gt;&lt;br /&gt;Did you try: thisXDocument.View.Window.Close(true); just for the sake of it?&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;&lt;br /&gt;Franck Dauché&lt;br /&gt;InfoPathDev</description></item><item><title>Re: Closing Form using ActiveWindow.Close()</title><link>https://www.infopathdev.com:443/forums/thread/14021.aspx</link><pubDate>Fri, 18 Nov 2005 04:03:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14021</guid><dc:creator>DavidCrabbe</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14021.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14021</wfw:commentRss><description>Thanks Franck.  My apologies for not being clear, when I try to close the form I am using:&lt;br /&gt;&lt;br /&gt;thisApplication.ActiveWindow.Close(true);&lt;br /&gt;&lt;br /&gt;It works fine when InfoPath has focus, but fails when another window has focus.&lt;br /&gt;&lt;br /&gt;</description></item><item><title>Re: Closing Form using ActiveWindow.Close()</title><link>https://www.infopathdev.com:443/forums/thread/14020.aspx</link><pubDate>Fri, 18 Nov 2005 03:44:12 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14020</guid><dc:creator>franck</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14020.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14020</wfw:commentRss><description>Hi David,&lt;br /&gt;&lt;br /&gt;Did you try:&lt;br /&gt;thisApplication.ActiveWindow.Close(true);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;&lt;br /&gt;Franck Dauché&lt;br /&gt;InfoPathDev</description></item><item><title>Re: Closing Form using ActiveWindow.Close()</title><link>https://www.infopathdev.com:443/forums/thread/14019.aspx</link><pubDate>Fri, 18 Nov 2005 03:26:01 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14019</guid><dc:creator>DavidCrabbe</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14019.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14019</wfw:commentRss><description>BTW, it's definitely the thisApplication.ActiveWindow.Close() code that is causing the exception.  &lt;br /&gt;&lt;br /&gt;I've wrapped the code in a try...catch section and can at least trap the error.</description></item><item><title>Closing Form using ActiveWindow.Close()</title><link>https://www.infopathdev.com:443/forums/thread/12684.aspx</link><pubDate>Fri, 18 Nov 2005 03:16:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12684</guid><dc:creator>DavidCrabbe</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12684.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12684</wfw:commentRss><description>I'm wondering if anyone else has encountered an issue with closing forms using C# and thisApplication.ActiveWindow.Close() in particular:&lt;br /&gt;&lt;br /&gt;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().  &lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;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?&lt;br /&gt;&lt;br /&gt;I've tried to regain the focus by using thisApplication.ActiveWindow.Activate() prior to calling Close() but to no avail.&lt;br /&gt;&lt;br /&gt;Thanks in advance,&lt;br /&gt;David.&lt;br /&gt;</description></item></channel></rss>