tomkuijsten / restup

Webserver for universal windows platform (UWP) apps
MIT License
114 stars 48 forks source link

Implementing custom Logger/LogFactory results in build errors #115

Closed borrillis closed 7 years ago

borrillis commented 7 years ago

When i implemented the classes according to the wiki : https://github.com/tomkuijsten/restup/wiki/Logging in a UWP BackgroundTask project, I get build errors like :

Error Type 'DebugLogFactory' implements interface 'Restup.WebServer.Logging.ILogFactory', which is not a Windows Runtime interface. All interfaces that are implemented by exported types must be Windows Runtime interfaces.

Error Method 'DebugLogFactory.GetLogger(System.String)' returns 'Restup.WebServer.Logging.ILogger', which is not a valid Windows Runtime type. Methods exposed to Windows Runtime must return only Windows Runtime types.

Error 'DebugLogFactory.GetLogger<T>()' is a generic method. Windows Runtime methods cannot be generic.

Error Windows Runtime class 'DebugLogger' has an invalid base type, 'Restup.WebServer.Logging.AbstractLogger'. Classes must derive either from System.Object or from a composable Windows Runtime class. Implementation inheritance is not allowed.

Jark commented 7 years ago

Hi @borrillis,

Since a background task is a windows runtime component it doesn't support exporting some of the features that .net offers.

I think there's two options to solve the above issue:

  1. make the DebugLogFactory internal or private so that it won't be included in the interface for the windows runtime component and thus won't be "an exported type"

  2. create a separate regular DLL with the rest server in it and reference that from the background task.

Hope this helps,

Jark

borrillis commented 7 years ago

Hi Jark, I ended up solving it using option 2 since I needed the class library for EFCore.

Thanks.