System.BadImageFormatException at Couchbase.Lite.Support.NetDesktop.Activate()

We have a Couchbase Lite 2.x Windows console application and we want to run it as a Windows Service. The console version of the app runs fine but I converted it to a Windows Service and when we try to start the service we get this error:

Exception Info: System.BadImageFormatException
at Couchbase.Lite.Support.NetDesktop.Activate()
at IN2L.EclipseSyncService.DatabaseManager.GetInstance()
at IN2L.EclipseSyncService.EclipseSyncService…ctor(Boolean)
at IN2L.EclipseSyncService.Program.Main(System.String)

Note: This service worked well under Couch Base Lite 1.44. But now we have upgraded to 2.1.2 . I did check the service installer dependencies and they look like they picked up the 2.1.2 dlls.

You mean on the same machine it fails as a service but works as a console app?

So I got it working. I have NOT enabled text logging

        example: NetDesktop.EnableTextLogging("c:\\temp");

When NetDesktop.Activate() is invoked, NetDestop looks for a subfolder “CouchbaseLite\Logs” and if it’s not there and you have not called NetDesktop.EnableTextLogging then you get the error. I created a post-build command that makes sure that the folder is created and the seamed to fix my issue.

The method you are referring to is the default directory for binary logs. You can override this with SetBinaryLogDirectory which is in the Support namespace.

This is deprecated as of the next release in favor of a more consolidated logging facility so this will be less of an issue.

EDIT I still don’t understand why this would cause the exception in question though.