Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a standalone, C# web service deployed as an EXE or Windows service?

Is it possible to create a C# EXE or Windows Service that can process Web Service requests? Obviously, some sort of embedded, probably limited, web server would have to be part of the EXE/service. The EXE/service would not have to rely on IIS being installed. Preferably, the embedded web service could handle HTTPS/SSL type connections.

The scenario is this: customer wants to install a small agent (a windows service) on their corporate machines. The agent would have two primary tasks: 1) monitor the system over time and gather certain pieces of data and 2) respond to web service requests (SOAP -v- REST is still be haggled about) for data gathering or system change purposes. The customer likes the idea of web service APIs so that any number of clients (in any language) can be written to tap into the various agents running on the corporate machines. They want the installation to be relatively painless (install .NET, some assemblies, a service, modify the Windows firewall, start the service) without requiring IIS to be installed and configured.

I know that I can do this with Delphi. But the customer would prefer to have this done in C# if possible.

Any suggestions?

like image 519
Jason Swager Avatar asked Jun 18 '09 16:06

Jason Swager


People also ask

Can C run on any machine?

If you write a C or C++ program that strictly complies with some standard, then the program should work on any platform that supplies a tool chain that complies with that standard. In that sense, C and C++ are cross-platform languages.

Can I create software with C?

We inferred that C is used in all spheres of hardware and software development, making it useful for upcoming software developers and software professionals, of course, who have great command over C to design complex interfaces.

Can I use C++ instead of C?

Compared to C, C++ has significantly more libraries and functions to use. If you're working with complex software, C++ is a better fit because you have more libraries to rely on. Thinking practically, having knowledge of C++ is often a requirement for a variety of programming roles.

Is C created by Microsoft?

The C# programming language was designed by Anders Hejlsberg from Microsoft in 2000 and was later approved as an international standard by Ecma (ECMA-334) in 2002 and ISO/IEC (ISO/IEC 23270) in 2003. Microsoft introduced C# along with .


4 Answers

Yes, it's possible, you may want to have a look at WCF and Self Hosting.

like image 146
Paulo Santos Avatar answered Oct 21 '22 10:10

Paulo Santos


Yes, it is possible (and fairly easy).

Here is a CodeProject article showing how to make a basic HTTP server in C#. This could easily be put in a standalone EXE or service, and used as a web service.

like image 44
Reed Copsey Avatar answered Oct 21 '22 08:10

Reed Copsey


One technology you might want to check out is WCF. WCF can be a bit of a pain to get into but there's a great screencast over at DNRTV by Keith Elder that shows how to get started with WCF in a very simple fashion.

http://www.dnrtv.com/default.aspx?showNum=135

like image 43
Antonio Haley Avatar answered Oct 21 '22 08:10

Antonio Haley


You could take a look at HttpListener in the .Net framework.

like image 1
Grokys Avatar answered Oct 21 '22 09:10

Grokys