ActiveX and Windows Service
-
Hi guys. I'm building a windows service that uses an ActiveX object. When I try to instantiate the ActiveX I get this error. Could not instantiate ActiveX control 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' because the current thread is not in a single-threaded apartment. I've changed the thread apartment style in the service, instantiated the ActiveX in a separate STA thread and still get the error. Have any of you been in a similar situation ? if so, have you found a solution ? Thanks in advance
Free your mind...
-
Hi guys. I'm building a windows service that uses an ActiveX object. When I try to instantiate the ActiveX I get this error. Could not instantiate ActiveX control 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' because the current thread is not in a single-threaded apartment. I've changed the thread apartment style in the service, instantiated the ActiveX in a separate STA thread and still get the error. Have any of you been in a similar situation ? if so, have you found a solution ? Thanks in advance
Free your mind...
Judging by the hits on Google, you're not the first to encounter this problem. Have you tried doing a search for activeX STA? That said, it seems odd that you'd want to instantiate ActiveX UI stuff in a Windows Service. Is this absolutely required? Could the service instead spawn some regular application with that uses the AX control?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: No, Not I - A poem by Holocaust escapee, chief rabbi, and Messiah-follower Daniel Zion The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Judging by the hits on Google, you're not the first to encounter this problem. Have you tried doing a search for activeX STA? That said, it seems odd that you'd want to instantiate ActiveX UI stuff in a Windows Service. Is this absolutely required? Could the service instead spawn some regular application with that uses the AX control?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: No, Not I - A poem by Holocaust escapee, chief rabbi, and Messiah-follower Daniel Zion The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Thanks for your reply. I know it looks odd. Let me explain a little further. The main function of the application is to print some kind of files in PDF. The service will "Watch" some folders to see if there are changes on the files, and if there are, a PDF copy (PDF pinting) will be made. To open those files, I need to use the ActiveX supplied by the vendor. All works fine in a Windows Form Application. But the problem comes with the service. How can I achieved what you suggest (Could the service instead spawn some regular application with that uses the AX control?) ? Thanks again
Free your mind...
-
Thanks for your reply. I know it looks odd. Let me explain a little further. The main function of the application is to print some kind of files in PDF. The service will "Watch" some folders to see if there are changes on the files, and if there are, a PDF copy (PDF pinting) will be made. To open those files, I need to use the ActiveX supplied by the vendor. All works fine in a Windows Form Application. But the problem comes with the service. How can I achieved what you suggest (Could the service instead spawn some regular application with that uses the AX control?) ? Thanks again
Free your mind...
Hi Guillermo Couple things to try: on the entry point of the service, place the [STAThread] attribute. (not sure if you've already tried this). If that doesn't work, perhaps you could have your service simply monitor the folders, and when changes are made on the files, launch a separate process (System.Diagnostics.Process) that is your application that uses the ActiveX control to do heavy lifting.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: No, Not I - A poem by Holocaust escapee, chief rabbi, and Messiah-follower Daniel Zion The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Hi Guillermo Couple things to try: on the entry point of the service, place the [STAThread] attribute. (not sure if you've already tried this). If that doesn't work, perhaps you could have your service simply monitor the folders, and when changes are made on the files, launch a separate process (System.Diagnostics.Process) that is your application that uses the ActiveX control to do heavy lifting.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: No, Not I - A poem by Holocaust escapee, chief rabbi, and Messiah-follower Daniel Zion The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Thanks Judah ! You gave me the direction. I tried including [STAThread] attributeand didn't work. Then I tried starting a new thread and setting the appartmentin STA, didn't work. Finally, tried starting the program with ProcessInfo, and the program started !. I'm going to see if the ActiveX works. I'll let you know if it works. Thanks again.
Free your mind...
-
Hi Guillermo Couple things to try: on the entry point of the service, place the [STAThread] attribute. (not sure if you've already tried this). If that doesn't work, perhaps you could have your service simply monitor the folders, and when changes are made on the files, launch a separate process (System.Diagnostics.Process) that is your application that uses the ActiveX control to do heavy lifting.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: No, Not I - A poem by Holocaust escapee, chief rabbi, and Messiah-follower Daniel Zion The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Thanks again Judah. It worked fine. I really appreciate for your guidance. I hope some day I can help you back. See you
Free your mind...