This repository has been archived on 2020-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
tdlib-fork/example/csharp
levlam c1afa189f3 Support multiple chat lists.
GitOrigin-RevId: 8adecce0ddf36bb2408eecc19b7f1fc8856151fc
2019-08-22 18:24:02 +03:00
..
.gitignore Add C# example. 2018-03-12 02:38:07 +03:00
README.md Improve Readme. 2018-07-08 03:18:46 +03:00
TdExample.cs Support multiple chat lists. 2019-08-22 18:24:02 +03:00
TdExample.csproj Add C# example. 2018-03-12 02:38:07 +03:00
TdExample.sln Add C# example. 2018-03-12 02:38:07 +03:00

TDLib C# example

This is an example of building TDLib with C++/CLI support and an example of TDLib usage from C#.

Building TDLib

  • Download and install Microsoft Visual Studio 2015 or later.
  • Download and install CMake; choose "Add CMake to the system PATH" option while installing.
  • Install vcpkg or update it to the latest version using vcpkg update and following received instructions.
  • Install zlib and openssl for using vcpkg:
cd <path to vcpkg>
.\vcpkg.exe install openssl:x64-windows openssl:x86-windows zlib:x64-windows zlib:x86-windows
  • (Optional. For XML documentation generation.) Download PHP. Add the path to php.exe to the PATH environment variable.
  • Download and install gperf. Add the path to gperf.exe to the PATH environment variable.
  • Build TDLib with CMake enabling .NET support and specifying correct path to vcpkg toolchain file:
cd <path to TDLib sources>/example/csharp
mkdir build
cd build
cmake -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg>\scripts\buildsystems\vcpkg.cmake ../../..
cmake --build . --config Release
cmake --build . --config Debug

Example of usage

After TDLib is built you can open and run TdExample project. It contains a simple console C# application with implementation of authorization and message sending. Just open it with Visual Studio 2015 or 2017 and run.

Also see TdExample.csproj for example of including TDLib in C# project with all native shared library dependencies.