Description
ProtectedKeyProvider.cs line 118 reads the encryption key file with File.ReadAllBytes() without retry logic. On Windows, antivirus or backup software can briefly lock files.
Code
encrypted = File.ReadAllBytes(path); // throws immediately on lock
Scenario
Windows Defender or backup agent momentarily locks the key file during a scan → IOException → service fails to start → requires manual restart after the lock clears.
Suggested Fix
Retry with short exponential backoff:
const int maxRetries = 3;
for (int attempt = 0; ; attempt++)
{
try
{
encrypted = File.ReadAllBytes(path);
break;
}
catch (IOException) when (attempt < maxRetries - 1)
{
Thread.Sleep(100 * (attempt + 1));
}
}
Description
ProtectedKeyProvider.csline 118 reads the encryption key file withFile.ReadAllBytes()without retry logic. On Windows, antivirus or backup software can briefly lock files.Code
Scenario
Windows Defender or backup agent momentarily locks the key file during a scan →
IOException→ service fails to start → requires manual restart after the lock clears.Suggested Fix
Retry with short exponential backoff: