473,322 Members | 1,566 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,322 software developers and data experts.

Callbacks into another assembly

Here's my problem. I've created a windows service using the Win32 app
instead of the .NET framework's System.ServiceProcess.ServiceBase and
I'm trying to use the RegisterServiceCtrlHandler win32 API call. It
works just fine when I compile all my code and classes in a normal
executable. However, when I throw it into a class library, it can't
seem to find the control handler function. It seems like it's a problem
with the callback into the external assembly. Any suggestions?

Thanks,
- David Hoyt

Oct 12 '05 #1
3 1208
I meant "Win32 API," no "Win32 app." Sorry 'bout that!

Oct 13 '05 #2
David wrote:
Here's my problem. I've created a windows service using the Win32 app
instead of the .NET framework's System.ServiceProcess.ServiceBase and
So this is a .NET app, but you've used platform invoke to make the
appropriate calls through Win32 to the SCM?
I'm trying to use the RegisterServiceCtrlHandler win32 API call. It
works just fine when I compile all my code and classes in a normal
executable. However, when I throw it into a class library, it can't
Now I am confused. A service is a *process*, why are you compiling it
into a library?

It is possible to host a DLL based service in svchost.exe, however, this
is not documented and presumably Microsoft does not support it. Is this
what you are trying to do?
seem to find the control handler function. It seems like it's a
problem with the callback into the external assembly. Any suggestions?


Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Oct 16 '05 #3
Hi Richard,

Thanks for your reply, I apologize for not explaining it clearly.
That's not exactly what I'm trying to do, but the p-invoke part is
correct. The ServiceBase class is an abstract base class used for
creating a service. It resides in its own dll that is referenced in
your own project, let's say. In your program, you would reference the
dll, create a class that derives from ServiceBase, override a few
methods, and compile your executable. The service is the compiled
program you made, but all the SCM calls are in the ServiceBase class
inside the referenced dll, much like System.ServiceProcess.ServiceBase.
The .NET framework's base class for a service does not reside in your
own executable - it's in its own dll in the GAC. Mine works almost
exactly the same. I hope that makes sense. So it's not a dll-based
service at all.

Oct 17 '05 #4

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

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
2
by: johny smith | last post by:
I cannot seem to figure out how to do instance based callbacks for some reason. I found one site on functors but I did not find it that helpful actually I just don't understand it. I have no...
5
by: Christopher Jastram | last post by:
I'm a self-taught programmer, so this might be a pretty dumb question. If it is, please point me in the right direction and I shall apologize profusely. I have a question regarding C++ and...
4
by: womanontheinside | last post by:
I have a library which was written in C, you call a function, it provides the result by a callback to specific function names. I am trying to wrap the calls to this inside a class, but this causes...
3
by: Tuxpal | last post by:
What are the pros/cons of using Callback mechanism in C? (Design perspective) What are the scenarios where it can be applied ? Tuxpal
1
by: Niklas | last post by:
Hi I have a remoting client/server application. The clients subscribes to a server event. All works fine if client is used as a window application, but when the client is used with No-Touch...
4
by: David | last post by:
Here's my problem. I've created a windows service using the Win32 app instead of the .NET framework's System.ServiceProcess.ServiceBase and I'm trying to use the RegisterServiceCtrlHandler win32...
9
by: zholthran | last post by:
Hi folks, after reading several threads on this issue (-> subject) I fear that I got a problem that cannot easily be solved by the offered workarounds in an acceptable way, at least not with my...
7
by: Dave Booker | last post by:
Is it possible to call a .NET 2.0 delegate from an event in a .NET 1.1 process? We have a class compiled with Framework 1.1 that has a public Event called 'Error.' That class is instantiated in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.