do you have stack trace of the error? You may check source code of https://github.com/pnp/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/AuthenticationManager.cs > GetAppOnlyAuthenticatedContext method and check why error can be thrown.
Also as an option instead of adding reference to OfficeDevPnP.Core.dll you may download source code of the library from github, add it as project to your solution (add .csproj) and debug the code in Visual Studio.
Alternatively since OfficeDevPnP.Core is deprecated nowdays you may try to switch to latest PnP.Framework and try to run your code with it.