Could not instantiate ActiveX control - WeOnlyDo Discussion board

Could not instantiate ActiveX control (General questions)

by sucrerey, Wednesday, January 19, 2005, 21:18 (7247 days ago)

Hey folks, hope I can get some help here. I have written a multi-threaded windows forms application that uses the AxwodSFTPLib.AxwodSFTP object. Once I got the form working the way I wanted I tried to turn it into a service that is able to interact with the desktop. It compiles fine, and there are no hinks when it tries to install as a service. However, the moment I try to start the service, the form containing the SFTP component will not initialize and I get the following error:

Could not instantiate ActiveX control {(the ActiveX guid)} because the current thread is not in a single-threaded apartment.

Any help is appreciated,
Ben ROberts

Re: Could not instantiate ActiveX control

by wodSupport, Wednesday, January 19, 2005, 21:23 (7247 days ago) @ sucrerey

I think first you should stop using wodSFTP.OCX, and switch to wodSFTP.DLL (COM Object) since you may have problem with licensing this way).

Anyway, what I think could solve your problem is to call OleInitialize API from within each new thread - this is a requirement I think.

BTW does this error have some error number? Which one is it?

Re: Could not instantiate ActiveX control

by sucrerey, Wednesday, January 19, 2005, 21:59 (7246 days ago) @ wodSupport

ok,.. switched to COM but it now fails during InitializeComponent() on the following line:

((System.ComponentModel.ISupportInitialize)(this.axwodSFTP1)).EndInit();

I assume this is where I should use the OleInitialize but I've never done this before in .NET and I can't find anything useful in the MSDN can I get moved to the next step? Or possibly pointed to a useful article on how to do this with .NET?

Thanks In Advance,
Ben

I think first you should stop using wodSFTP.OCX, and switch to wodSFTP.DLL (COM Object) since you may have problem with licensing this way).

Anyway, what I think could solve your problem is to call OleInitialize API from within each new thread - this is a requirement I think.

BTW does this error have some error number? Which one is it?

Re: Could not instantiate ActiveX control

by wodSupport, Wednesday, January 19, 2005, 22:06 (7246 days ago) @ sucrerey

Ben,

I'm not sure either. Can you zip your project and send it to techsupport@weonlydo.com , so I can try?