473,386 Members | 1,699 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,386 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 1211
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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.