Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I design a .NET (C#) for a program that needs to run as a Windows service but also have a web interface?

I am designing a piece of software that needs to operate different pieces of hardware based mainly on a schedule but it also needs to have a web interface for configuring settings, configuring the schedule, and possibly even manually controlling the hardware. I'm not sure how to design the architecture of software like this.

One thought that I have had was to create a Windows service that does the communication with the hardware as well as "publishing" web services through WCF and then having an ASP.NET application that then controls the Windows service through WCF. This approach seems to be a lot of work for what I'm trying to accomplish.

Could someone please give me some direction whether or not this is a good approach, and even give me a better way to do it if one exists?

Thanks! Joel

like image 687
hjoelr Avatar asked Mar 18 '10 23:03

hjoelr


People also ask

Can I use .NET with C?

. NET Framework is an object oriented programming framework meant to be used with languages that it provides bindings for. Since C is not an object oriented language it wouldn't make sense to use it with the framework.

Which software is used for .NET programming?

C# and Visual Basic are programming languages designed for creating a variety of applications that run on . NET.


1 Answers

You can instantiate a WCF endpoint as a TCP service from within the Windows service, as explained on MSDN: How to: Host WCF in a Windows Service Using TCP .

From there, it is relatively straightforward to consume that endpoint in an ASP.NET application (same as consuming any other WCF endpoint).

In the absence of any compelling reasons to do otherwise, this is probably the approach I would take. Your only other option is to use some other form of IPC, such as memory-mapped files or named pipes. WCF is a lot easier to get up and running.

like image 104
Aaronaught Avatar answered Oct 21 '22 12:10

Aaronaught