• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

How to keep COM object alive in .NET windows service?

I have created windows service which instantiates COM object in OnStart event of the service. While the service OnStart is in process, I can see the COM EXE in running processes (in task manager) but once the service is completely started, the COM instance gets destroyed. I googled on this in which I got an answer to implement STA thread process to instantiate COM object. But after implementing threading, I now get error as "Retrieving the COM class factory for component with CLSID {D66B3D9C-D465-46B8-BFB4-F63F04FB203C} failed due to the following error: 80080005."

Please help me out...
0
yatinganesh
Asked:
yatinganesh
  • 2
2 Solutions
 
Anurag ThakurTechnical ManagerCommented:
to implement STA in windows service have a look at the foloowing sample
http://discuss.joelonsoftware.com/default.asp?dotnet.12.459213.6
0
 
Anurag ThakurTechnical ManagerCommented:
the above link might throw an exception on stop i suppose...
there was one more link for Using COM Interop on a Single Threaded Apartment from a Windows Service on EE
http://www.experts-exchange.com/Microsoft/Development/.NET/Visual_Studio_.NET_2005/Q_23058828.html
0
 
yatinganeshAuthor Commented:
We found that the COM component we were using was expired. We brought the licensed copy and now it works fine even without threading. Apology for the trouble.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now