Archived

This forum has been archived. Please start a new discussion on GitHub.

Ice::Service Class in C#?

Just got some free-time again to work on my pet project and I recoded the my network library (which uses Ice) from C++ to C#.

I tell you guys, I really appreciate the support for C#, its really way easier than C++. I was able to recode using a the normal console application which just use the waitForShutdown() function call.

So, I kept thinking that converting it into a service would be a snap since it was really easy with C++ when you just use the Ice::Service singleton class.

Well, to make my rather winded story short, theres no way I could create a an Ice::Service class. :confused:

Am I correct in assuming that IceCS.dll does not support the Ice::Service class? Is there a way around this? I would appreciate any suggestions or help. :D

Thanks.

Comments

  • mes
    mes California
    Hi Alex,

    You're correct, we don't have a C# version of Ice::Service yet, but it's something we intend to add eventually. Meanwhile, you could start by deriving your own class from System.ServiceProcess.ServiceBase, as described here.

    Take care,
    - Mark
  • Hi Alex,

    why don't you simply use iceboxnet? This eventually simplifies your implementation as you don't have to care about the bootstrapping etc. Simply implement your classes and 'go'.

    regs,

    Stephan
  • @mes

    Yap, I did create a class using the .NET ServiceBase ... unfortunately, there is an added bonus with using the Ice::Service class. You can test your code without loading it as a service first, so no need to recompile. :rolleyes:

    @stephan

    Thanks for the suggestion ... will give iceboxnet a try. :)
  • Hello Alex,
    I am working on a C# Ice windows service currently, using ServiceBase, and Ice.Application.

    I started with a console app and in my Ice:Application run method I create the communicator, then the object adapter, activate the adapter and then waitForShutdown. When I try the same thing within the context of a service, the service will sort of hang with the waitforshutdown.
    If I dont waitforshutdown in the run method, seems to work.

    I was wondering, how did you handle waitForShutdown() within the service?

    Thanks,
    Powell
  • Hello Alex,
    I am working on a C# Ice windows service currently, using ServiceBase, and Ice.Application.

    I started with a console app and in my Ice:Application run method I create the communicator, then the object adapter, activate the adapter and then waitForShutdown. When I try the same thing within the context of a service, the service will sort of hang with the waitforshutdown.
    If I dont waitforshutdown in the run method, seems to work.

    I was wondering, how did you handle waitForShutdown() within the service?

    Thanks,
    Powell

    Nope. The waitForShutDown() function didn't work for me too. I actually removed that code ...

    I'll be looking into C++.NET as soon as I have free time for my project. What I'm thinking is leaving ICE implementation in C++ but the code will call the C# classes which actually does the work.
  • matthew
    matthew NL, Canada
    You cannot call waitForShutdown as it blocks the thread until the communicator has been shutdown. If you do this windows thinks your service is broken and assumes it fails. Anyway, you do not need to call waitForShutdown() since the purpose of this is API call is to block the main thread of your application (so it does not terminate your application) until the server is told to terminate. With a windows service you don't have to do this -- the interaction model is different.

    I recommend you read Mark Spruiells article in issue 10 of the newsletter. It refers to the C++ Ice::Service class -- however the basic ideas are all the same in C#. If you look at the impl of this class you can see how the hooks into your application are arranged from the core Windows service calls.
  • matthew wrote:
    I recommend you read Mark Spruiells article in issue 10 of the newsletter. It refers to the C++ Ice::Service class -- however the basic ideas are all the same in C#. If you look at the impl of this class you can see how the hooks into your application are arranged from the core Windows service calls.

    Thanks for pointing out the article. :)