Only do this if the problem persists and you trust the source of WinDivert.
catch (Exception ex)
Windows has strict security policies, especially concerning kernel-level drivers. The WinDivert installation error is typically a direct result of one of these Windows security features. Here are the most common causes, each tied to specific Windows protection mechanisms: Only do this if the problem persists and
Modern antivirus engines (Bitdefender, Kaspersky, Malwarebytes, and even Windows Defender) sometimes flag WinDivert as a "potentially unwanted driver" because it can be used for man-in-the-middle attacks. Only do this if the problem persists and
Security software is a common culprit.