[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Strange problems with service in managed c++ and (OnStart and NotifyIcon)

Rolf Molini

12/21/2002 9:46:00 PM

Hi everybody,

I'm trying to write a service program in c++ with managed extensions but I
am encountering strange problems and behaviours.
What I have 'til now is pretty simple:

A service derived from ServiceBase which does nothing but write some entries
to EventLog (which is not full at all), show some MessageBoxes when
starting, stopping, pausing and continuing (OnStart, OnStop, OnPause,
OnContinue-methods) and uses an instance of NotifyIcon with a small context
menu. One entry of the context menu is connected via EventHandler delegate
to a simple routine which shows a message box as well, the NotifyIcon itself
is connected likewise (add_Click).

All this is simply done to check if the basics of the service will work.

Now, what I see is this:
The service can be installed via Windows Installer, it can be started,
stopped, paused and continued as well. Principally, the service is runnable
and works. But:

1.) Any code placed within the OnStart-method is NOT executed, whatever it
may be (EventLog-entries, MessageBoxes, ...). Code within OnStop, OnPause,
OnContinue are executed. Unfortunately, since not even EventLog-entries
work, I have no way to debug OnStart at the moment. I might well write a
dummy service and try to start my service from dummy service for debugging,
but I would have to start my service from the OnStart-method of the dummy
service...

2.) When I run the service executable directly via double-click, the
UI-behaviour is working fine: The NotifyIcon appears, a click on it shows a
MessageBox, a right-click opens the context menu, a click on an entry shows
a MessageBox. Of course, 30 secs later the SCM reports that the service
could not be started.
When started via service manager, the NotifyIcon appears as well and shows
OnMouseOver-Text, but no reaction to any clicks is shown UNTIL THE SERVICE
IS STOPPED. At this moment, all raised events appear sequentially (many
MessageBoxes). Still, the context menu is never showing up at all.

3.) Frequently, after I have tried to use the NotifyIcon of the service, I
get an exception of explorer.exe referencing memory that "can not be
written" which kills the complete windows session. During the forced
shutdown of all frozen processes that are running, I noticed one called
DirectDBNotifyWndProc. My perception is, that the correct events are raised
but the called methods never find the right windows box to show up e.g. the
context menu.

In NotifyIcon or ContextMenu I did not find any way to provide for a windows
handle, so I'm not sure how to tell the context menu where to appear.
The other big problem at the moment is the OnStart-method wich will not
execute any code, despite of the service being runnable.

If any of you might know of some cures, I would very appreciate.

Thanks
Rolf