Create Custom C# Services
You can create Custom C# Services in DLLs for Dnn and Oqtane.
System Requirements
- Custom Services are compiled into a DLL
- They must register themselves at startup of the Application (Dnn, Oqtane)
- In DNN you must have at least Dnn 9.4 and 2sxc 13
- 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:
- Your Service must have an empty constructor like
MyService()
- ...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).