C# win form sending a message on telegram to a pr. channel exception error

Gennady Gurin 251 Reputation points
2026-10-22T02:27:00.1833333+00:00

Sending a message to a private channel on Telegram,

not sure why I get exception message when running code.

I attached 2 files.

https://1drv.ms/i/c/4bb745d09a980e0c/IQAgTbHfYIUFR7SS9C1J1elwAcWxLDv1-fFFqxvo8SM3YXo?e=EFa1FV

https://1drv.ms/i/c/4bb745d09a980e0c/IQBkO7GluIWcQYgtIXCHiKQgAYTIu7Li8xnhoJV0brKMwFU?e=N6o6TS

Anyone knows,

Thanks in advance.

Developer technologies | C#
Developer technologies | C#

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.

0 comments No comments

Answer accepted by question author
Brian Pham (WICLOUD CORPORATION) 1,340 Reputation points Microsoft External Staff Moderator
2026-10-22T08:30:25.61+00:00

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:

  1. Check the project’s <TargetFramework> or <TargetFrameworkVersion> value.
  2. In Visual Studio, restore the NuGet packages, clean the solution, and rebuild it
  3. If the issue persists, close Visual Studio and remove the project's bin and obj folders before rebuilding
  4. In Manage NuGet Packages for Solution > Consolidate, align the Telegram.Bot and System.Text.Json versions across all projects.
  5. Check for manually added references to System.Text.Json.dll and verify that they are consistent with the NuGet package configuration.
  6. 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.

Was this answer helpful?

2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.