<?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>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>InfoPath FormControl on STA worker thread</title><link>https://www.infopathdev.com:443/forums/thread/39317.aspx</link><pubDate>Sun, 08 Mar 2009 09:43:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:39317</guid><dc:creator>Rob Ford</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/39317.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=39317</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class="post-text"&gt;
                &lt;p&gt;I have a .NET class that
exposes two public methods: one to create an InfoPath form and another
to Export to one of the supported formats. I’m using the Microsoft
FormControl to do this. It’s hosted by a Form that does not get
displayed. I get called by a Winforms app, but on a MTA worker thread
instead of the UI thread. So I create a STA thread and execute on
that, which works exactly once and then results in this exception:&lt;/p&gt;

&lt;p&gt;System.InvalidOperationException was unhandled Message=&amp;quot;Unable to
get the window handle for the &amp;#39;FormControl&amp;#39; control. Windowless ActiveX
controls are not supported.&amp;quot; Source=&amp;quot;System.Windows.Forms&amp;quot; StackTrace:
at System.Windows.Forms.AxHost.EnsureWindowPresent() at
System.Windows.Forms.AxHost.InPlaceActivate() at
System.Windows.Forms.AxHost.TransitionUpTo(Int32 state) at
System.Windows.Forms.AxHost.CreateHandle() at
System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at
System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at
System.Windows.Forms.AxHost.EndInit() at
InfoPathCreateStaThreadTest.FormControlHost.InitializeComponent() in
C:\Windows\Temp\InfoPathCreateStaThreadTest\InfoPathCreateStaThreadTest\FormControlHost.Designer.cs:line
65&lt;/p&gt;

&lt;p&gt;After some experimenting, I started to suspect this is a message
pumping problem. I then came across this, which makes me more strongly
suspect so: &lt;a href="http://blogs.msdn.com/cbrumme/archive/2004/02/02/66219.aspx" rel="nofollow"&gt;http://blogs.msdn.com/cbrumme/archive/2004/02/02/66219.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I tried various methods of pumping messages with no luck. I should
mention that the alternative of automating the InfoPath app is not
viable unless I can figure out how to hide the app. &lt;/p&gt;

&lt;p&gt;Any help would be much appreciated. &lt;/p&gt;

            &lt;/div&gt;</description></item></channel></rss>