Table of Contents

Create Custom C# Services

You can create Custom C# Services in DLLs for Dnn and Oqtane.

you are here (click to zoom) - discover the stack

System Requirements

  1. Custom Services are compiled into a DLL
  2. They must register themselves at startup of the Application (Dnn, Oqtane)
  3. In DNN you must have at least Dnn 9.4 and 2sxc 13
  4. In Oqtane any version of Oqtane and compatible 2sxc will do

Constructor Requirements

Any class / interface can be used as a Service, but there are some important requirements in regards to the Constructor:

  1. Your Service must have an empty constructor like MyService()
  2. ...or a constructor that only expects objects which themselves are known services, like MyService(ToSic.Sxc.Services.IConvertService converter)

Register a Service in Dnn

Dnn 9.4 introduces a new interface DotNetNuke.DependencyInjection.IDnnStartup. Use this to create a class which registers your services. Check out Andrew Hoeflings awesome tutorial.

Register a Service in Oqtane

Oqtane Server uses the interface Oqtane.Infrastructure.IServerStartup to register services (docs).

Oqtane client uses the interface Oqtane.Service.IClientStartup for this (docs).