tdlight/example/csharp
2024-05-31 01:17:34 +03:00
..
.gitignore Improve relative paths in .gitignore. 2024-05-31 01:17:34 +03:00
README.md Update pinned vcpkg commit hash. 2023-11-26 11:10:08 +03:00
TdExample.cs Add registerUser.disable_notification. 2024-01-29 16:43:42 +03:00
TdExample.csproj Update name of linked OpenSSL DLLs in examples. 2023-11-28 21:09:44 +03:00
TdExample.sln Update C# example build instructions. 2020-02-04 01:36:52 +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 gperf, zlib, and openssl using vcpkg:
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
git checkout cd5e746ec203c8c3c61647e0886a8df8c1e78e41
.\bootstrap-vcpkg.bat
.\vcpkg.exe install gperf:x64-windows gperf:x86-windows 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.
  • 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 -A Win32 -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg>/scripts/buildsystems/vcpkg.cmake ../../..
cmake --build . --config Release
cmake --build . --config Debug
cd ..
mkdir build64
cd build64
cmake -A x64 -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 later and run.

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