How do I fix the error “Could not load file or assembly ‘System.Text.Json, …”?

I had this issue because I had a dependency on Microsoft.Extensions.Configuration.Json in project B that targeted netstandard. Microsoft.Extensions.Configuration.Json requires System.Text.Json when starting .NETStandard, but not dotnetcore. My problem came when in project A that targeted dotnetcore3.1 referenced project B. At runtime, AWS Lambda was still expecting System.Text.Json to be there. To resolve the issue, I … Read more

System.DirectoryServices.AccountManagement.PrincipalContext broken after Windows 10 update

One final Google before I started rolling back my machine to the previous build and I found this https://connect.microsoft.com/IE/feedback/details/1904887/windows-10-insider-preview-build-10565 the problem is caused by missing registry entries in HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion, specifically: RegisteredOwner and RegisteredOrganization EDIT: Run the Registry Editor by pressing Windows R and typing regedit.exe. Browse to the location above Just right click on … Read more

HttpURLConnection java.io.FileNotFoundException

You can get a FileNotFoundException from HttpUrlConnection (and OkHttpClient) if your server returns >= HTTPStatus.BAD_REQUEST (400). You should check the status code first to check what stream you need to read. int status = connection.getResponseCode(); if(status >= HttpStatus.SC_BAD_REQUEST) in = connection.getErrorStream(); else in = connection.getInputStream(); HttpStatus deprecated. Latest syntax seems to be: InputStream inputStream; int … Read more

Python’s “open()” throws different errors for “file not found” – how to handle both exceptions?

In 3.3, IOError became an alias for OSError, and FileNotFoundError is a subclass of OSError. So you might try except (OSError, IOError) as e: … This will cast a pretty wide net, and you can’t assume that the exception is “file not found” without inspecting e.errno, but it may cover your use case. PEP 3151 … Read more