473,388 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

C# Windows Service unable to receive COM callback events

SPG
Hi,

We have a standard windows app writeen in C# that uses an ActiveX dll to
send us events. This works fine as a Windows app, but as soon as we compile
as a service, no more events.

I have been told that there is no message pump provided to the service, and
therefore the events from the dll cannot be serviced.

Has anyone ever come across this? How did you get around it?
I have tried creating a message pump using Application.Run() but I don't
think I am doing the right thing.

Any help would be greatly appreciated.

Steve
Nov 16 '05 #1
1 2366
Steve,

Calling the static Run method on the Application class isn't going to do
anything for you. What you have to do is set the thread up that you are
running your code on to join an apartment. Now, I believe that the calls to
your component for starting, stopping, pausing, etc, etc, will come in on
the same thread, so what you might want to do is set the apartment state
when the service starts (and you MUST do this before you create any COM
components), by setting the ApartmentState property to MTA or STA, depending
on whether or not you want a single-threaded apartment or to join the single
multi-threaded apartment for the process.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SPG" <st*******************@nopoo.blueyonder.co.uk> wrote in message
news:Bv*********************@news-text.cableinet.net...
Hi,

We have a standard windows app writeen in C# that uses an ActiveX dll to
send us events. This works fine as a Windows app, but as soon as we compile as a service, no more events.

I have been told that there is no message pump provided to the service, and therefore the events from the dll cannot be serviced.

Has anyone ever come across this? How did you get around it?
I have tried creating a message pump using Application.Run() but I don't
think I am doing the right thing.

Any help would be greatly appreciated.

Steve

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Cantankerous Old Git | last post by:
I am trying to write a program that I hope to get working as a command-line app to start with, and then eventually use a windows service wrapper to call it as a service. Its purpose is to attach...
0
by: Steve - DND | last post by:
We are continually receiving timeout, and "Unable to write data to the transport connection" errors while using the System.Net.HttpWebRequest class from an ASP.Net web page. Below are the two...
5
by: Julia | last post by:
Hi, I am creating a windows service which host a remote object that can be connected by other application (desktop applications and asp.net) and I wonder which type of UI window application...
0
by: developer | last post by:
I am trying to get a custom provider to receive health monitoring events in vb.net, whidbey beta 1. I have a health monitoring setup like this in my web.config: <healthMonitoring enabled="true">...
4
by: SimpTheChimp | last post by:
I am going to write (my first) Windows Service. What I want is this service to run automatically when the computer/server is booted.... But also, to display an icon in the system tray whenever any...
2
by: Haxan | last post by:
Hi, I have an unmanaged C++ dll that consumes a web service using NTLM proxy authentication. I was able to consume the web service and get the results when using .Net runtime 1.1. When I...
0
by: =?Utf-8?B?RGlvZ28gQWx2ZXM=?= | last post by:
Greeting Nicholas, Thanks for your answer but I'm pretty new in this stuff.... I already have a class that inherits the MArshalByRefObject and I use it to get answers from the server like...
1
by: McKool | last post by:
Hello Group, I'm writting a Windows Services under C# to get some USB events. Because the ServiceBase class does not supports the SERVICE_CONTROL_DEVICEEVENT handler, I'm using P/Invoke to call...
0
by: dom_perron | last post by:
Hi, I have a problem when I try to start an application using MSMQ from a Windows Service. The application runs on a server. The client send a message to a public queue created on the server,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.