tags:

views:

201

answers:

2

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 an MTA worker thread instead of the UI thread. So I create an STA thread and execute on that, which works exactly once and then results in this exception:

System.InvalidOperationException was unhandled Message="Unable to get the window handle for the 'FormControl' control. Windowless ActiveX controls are not supported." Source="System.Windows.Forms" 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

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: http://blogs.msdn.com/cbrumme/archive/2004/02/02/66219.aspx

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.

Any help would be much appreciated.

A: 

I'm researching the same error and found this: http://social.msdn.microsoft.com/Forums/en-US/clr/thread/9c36e5d3-a75c-4760-9070-5dbaf188992b/ which attributes the problem to DEP being unexpectedly turned on and provides a fix. I don't know yet if this will solve my problem.

mlo
A: 

Thanks for your reply. Sorry for the long delayed reply on my end. DEP is not causing the problem for me. I ended up automating the InfoPath app vs. using the FormControl. Best of luck getting your issue resolved!

Rob

related questions