ActiveX User Control

Good Day All,

I am having an issue that has left me bamboozled. I have an ActiveX User Control written using Visual Basic 6.0. Using Visual Studio 2005 I add the control to my Toolbox. I then drag the control onto a Panel control that is on a form. That is it. I don't write any code at all. When I run the program I get the following error:

Cross-thread operation not valid: Control 'Panel1' accessed from a thread other than the thread it was created on
The error appears right away and the form is never rendered to the screen. This happens if I try creating the Windows Form project in either VB.NET or C#.NET. However, if I follow the same steps in Visual C++.NET then the application will start and the form will show up like it is suppose to.

I am confused by this. There has to be something going on under the hood that allows C++ to handle this when the other languages don't. If anyone has any ideas I would appreciate it.
Thanks!

Dan DeLuca

[978 byte] By [DanD] at [2007-12-16]
# 1
This sounds like a known issue with the Visual Studio hosting process. The Visual Studio hosting process starts up a main thread and then creates a new UI thread that the application is run on. Some ActiveX controls do not support running on a UI thread that is not the main thread, hence this exception is being thrown.

The workaround is to disable the Visual Studio hosting process. To do this, open the project proeprty designer and selet the Debug tab. Then uncheck the "Enable the Visual Studio hosting process" checkbox.

VS host gives a performance boost to the F5 scenario and also enables the debug in security zone functionality. You will not be able to access these features if VS host is disabled.

Hope this helps.

- mike

MikeHarsh at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...