This document describes how to quickly integrate the Tencent Cloud TRTC SDK for C# on Windows into your project.
This document uses the creation of a simple Winform project as an example to describe how to integrate the SDK for C# into a Visual Studio project.
Download the SDK, decompress it, and open the files, including:
Directory Name | Description |
---|---|
xxxDemo | Source code of the demos for C++ and C# |
CPlusPlus | SDK library file depended on by the 32/64-bit SDK for C++ |
CSharp | SDK library file depended on by the 32/64-bit SDK for C# |
In the example in this document, you only need to import the C# version of the SDK files into the SDK directory.
Open Visual Studio and create a Winform application named TRTCCSharpDemo
.
Copy the extracted SDK folder to the directory where TRTCCSharpDemo.csproj
is located.
If you only need the SDK for C#, you can delete the
CPlusPlus
directory under the SDK path.
Step 4.1. Add references
Find Configuration Manager in the Build directory of Visual Studio and open it.
Select New from the Active solution platform drop-down list and the New Solution Platform dialog box will appear.
Type or select the new platform and click OK.
Repeat substep 2 to substep 3 as needed to create solution platforms that need to be supported.
Open the folder where the TRTCCSharpDemo project is located and edit the TRTCCSharpDemo.csproj
file with a text editor.
Add the following content to the <itemGroup>
label in the TRTCCSharpDemo.csproj
file:
// Add references to different platforms
<Reference Include="ManageLiteAV" Condition="'$(Platform)' == 'x64'">
<HintPath>SDK\CSharp\Win64\lib\ManageLiteAV.dll</HintPath>
</Reference>
<Reference Include="ManageLiteAV" Condition="'$(Platform)' == 'AnyCPU'">
<HintPath>SDK\CSharp\Win64\lib\ManageLiteAV.dll</HintPath>
</Reference>
<Reference Include="ManageLiteAV" Condition="'$(Platform)' == 'x86'">
<HintPath>SDK\CSharp\Win32\lib\ManageLiteAV.dll</HintPath>
</Reference>
Step 4.2. Add the copy command
set Platform=Win64
SETLOCAL ENABLEDELAYEDEXPANSION
if $(PlatformName)==x86 (
set Platform=Win32
)
copy /Y "$(ProjectDir)SDK\CSharp\!Platform!\lib\*.dll" "$(ProjectDir)$(OutDir)"
ENDLOCAL
Step 4.3. Modify the debugging environment
Open the properties page of the TRTCDemo, select Build, and set Platform to the solution platform in the top menu bar as shown below:
Add a label control in the designer of Form1.cs
as shown below:
Open the Form1.cs
code file and add the following code:
using System.Windows.Forms;
using ManageLiteAV; // 1. Add namespace reference
namespace TRTCCSharpDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// 2. Get an `ITRTCCloud` instance and print the SDK version number
ITRTCCloud lTRTCCloud = ITRTCCloud.getTRTCShareInstance();
this.label1.Text = "SDK version : " + lTRTCCloud.getSDKVersion();
// 3. The `IRTTCCloud` instance needs to be manually terminated at the end of use
ITRTCCloud.destroyTRTCShareInstance();
}
}
}
Press F5 to run and print the version number of the SDK as shown below:
Error CS0246: The type or namespace name "ManageLiteAV" could not be found (are you missing a using directive or an assembly reference?)
System.BadImageFormatException: "Could not load file or assembly "ManageLiteAV, Version=2.0.7152.18518, Culture=neutral, PublicKeyToken=null" or one of its dependencies. An attempt was made to load a program with an incorrect format."
System.IO.FileNotFoundException: "Could not load file or assembly "ManageLiteAV.dll" or one of its dependencies. The specified module could not be found."
Was this page helpful?