Why the code works in GUI or console application but doesn't work in a system service?

There are several things to check in this situation:

If the GUI/console application and the service are different applications, then be sure that you have copied *all* the code related to SecureBlackbox from the GUI/console application to the service. Check that all properties are set in the same way (as they are set in code, you can just copy the block of code that sets the properties). If any event is handled, remember to copy all event handler code as well.

Next, in .NET check that your service application references and loads all needed SecureBlackbox assemblies. For example, for SFTP functionality it's not enough to reference SecureBlackbox.SFTP.dll. You also need SecureBlackbox.dll, SecureBlackbox.SSHCommon.dll, SecureBlackbox.SSHClient.dll and SecureBlackbox.SFTPCommon.dll

If the application is the same and is running in different modes (as a GUI/console application and as a service), then you need to check the users permissions for all the involved files, i.e. for assemblies, external keyrings, certificates or key files which are loaded by the application. It can happen that the user SYSTEM (under which the services are run by default) doesn't have the rights to access certain folders or files.

Finally, ensure that the data is loaded correctly from the external files. If you have a relative path to the file, check that this path points to the same correct files in UI/console mode and in service mode. It's possible that when you load a key or certificate, they are not loaded correctly in service mode due to an incorrect file path.

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now