Could not instantiate ActiveX control (General questions)
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
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
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
Ben,
I'm not sure either. Can you zip your project and send it to techsupport@weonlydo.com , so I can try?