It's unclear which version of .NET you use, because ".NET 4.0.30319" applies to any .NET Framework 4.x version, but this actually looks like a known bug in .NET Framework 4.5.
Microsoft used to have a hotfix for this, but unfortunately, it's no longer available.
Upgrading to a more recent version of .NET Framework should resolve the issue. The recommended version to upgrade to is .NET Framework 4.6.2, because earlier 4.5/4.6 versions will reach end-of-support as soon as next month.