SecureBlackbox 16: Why does the code work in a GUI or console application but not in a system service?

Note: This article applies only to SecureBlackbox Legacy. For future development please consider using the latest version.

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 the 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.

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.