// Sign the app (where BinaryFile is the filename of the .hex file to sign) try { AppSigner Signer = new AppSigner(AppSigner.Mode.DetectType); // Get the key file string KeyFile = Signer.GetKeyFile(BinaryFile); if (KeyFile == "") throw new Exception("Couldn't find the key file."); // Get the output filename string SignedAppFilename = Signer.FormatOutput(BinaryFile); if (SignedAppFilename == "") throw new Exception("Couldn't establish output filename."); // Sign the bugger int Signed = Signer.Sign(BinaryFile, KeyFile, SignedAppFilename); if (Signed != 0) throw new Exception(Signer.GetErrorMessage(Signed)); } catch (Exception ex) { // Didn't work as it should DisplayError(ErrorType.Error, "Could not sign application: " + ex.Message); }