Skip to Main Content
Hands-On Microservices with C#
book

Hands-On Microservices with C#

by Matt Cole
June 2018
Intermediate to advanced content levelIntermediate to advanced
254 pages
6h 9m
English
Packt Publishing
Content preview from Hands-On Microservices with C#

Our code

Now that we have created our project, we need to talk about how we populate our program.cs file. This is where our service will be spawned from, and where Topshelf will really show its power. Here's what our fully populated program.cs file looks like. I have highlighted some areas that I want you to pay close attention to and understand:

static void Main(string[] args){var builder = new ContainerBuilder();

Registering our service:

builder.RegisterType<MemoryMicroService>().AsImplementedInterfaces().AsSelf()?.InstancePerLifetimeScope();

Registering our logger:

builder.RegisterType<Logger>().SingleInstance();var container = builder.Build();

Watching for log4net configuration changes:

XmlConfigurator.ConfigureAndWatch(new FileInfo(@".log4net.config")); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Microservices with ASP.NET Core

Building Microservices with ASP.NET Core

Kevin Hoffman
.NET Core Microservices

.NET Core Microservices

Piotr Gankiewicz
Microservices .NET Core Masterclass

Microservices .NET Core Masterclass

Piotr Gankiewicz, Dariusz Pawlukiewicz
Enterprise Application Architecture with .NET Core

Enterprise Application Architecture with .NET Core

Ganesan Senthilvel, Ovais Mehboob Ahmed Khan, Habib Qureshi

Publisher Resources

ISBN: 9781789533682Supplemental Content