An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Hi Gennady Gurin ,
Thank you for sharing the complete error message.
The failure occurs before the request reaches Telegram. The runtime is attempting to load: System.Text.Json, Version=8.0.0.0 but the System.Text.Json assembly available at runtime likely does not match the assembly identity expected by Telegram.Bot or one of its dependencies.
Please try the following:
- Check the project’s <TargetFramework> or <TargetFrameworkVersion> value.
- In Visual Studio, restore the NuGet packages, clean the solution, and rebuild it
- If the issue persists, close Visual Studio and remove the project's bin and obj folders before rebuilding
- In Manage NuGet Packages for Solution > Consolidate, align the Telegram.Bot and System.Text.Json versions across all projects.
- Check for manually added references to System.Text.Json.dll and verify that they are consistent with the NuGet package configuration.
- Restore the NuGet packages and rebuild the solution.
After rebuilding, check the DLL’s assembly identity by updating and running this command for example:
[System.Reflection.AssemblyName]::GetAssemblyName( "C:\Path\To\Application\bin\Debug\System.Text.Json.dll" ).FullName
Compare the result with:
System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
If the project targets .NET Framework, also add the following to the .csproj file:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
If the project targets .NET 6 or later, do not add a .NET Framework binding redirect. If the issue persists, please replace ex.Message with ex.ToString() and provide:
- The project’s target framework
- The Telegram.Bot version
- The System.Text.Json package version
- The PowerShell command output
- The complete exception output by change ex.Message to ex.ToString()
Please remove any sensitive information, including your bot token, before sharing code or logs.
If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation. Thank you.