From the comments, I realized maybe it is just outdated library issue, aaand it was. I changed my project from .net 6.0 to .net 8.0 and updated libraries accordingly then the code works fine. Thanks "President James K. Polk" and "Progman" for comments