Configuring a Sample Project

The huaweicloud-sdk-dis-net- X.X.X.zip package downloaded from SDK Download provides a sample project. You can use a development tool (such as Microsoft Visual Studio) to compile and run the sample project on a local device. You can also develop applications based on the sample project. The sample project code is available in [$path]\huaweicloud-sdk-dis-net-X.X.X\DIS .NET SDK\DIS .NET SDK.

Sample Project File

Description

demo

Sample code file, which contains sample codes of net35 and net45.

net35

Contains:

  • Third-party log library file log4net.dll
  • DIS library file
  • Related dependency file *.dll

net45

Contains:

  • Third-party log library file log4net.dll
  • DIS library file
  • Related dependency file *.dll

config

Contains the dis.properties file that records the DIS parameter configurations and the version.properties file that records the version information.

Procedure

  1. Decompress the huaweicloud-sdk-dis-net-X.X.X1.2.3.zip package downloaded from SDK Download to obtain the dis-sdk-.NET package and sample project.
  2. Start Visual Studio and choose File > New > Project. The New Project dialog box is displayed.
  3. Choose Templates > Visual C# > Console Application.

    Figure 1 Creating a console application

  4. Right-click the new project and choose Properties from the shortcut menu. Change the version of Target framework to .Net Framework 3.5. In the displayed dialog box, click OK.

    Figure 2 Changing the framework version.

  5. In Visual Studio, right-click the project and choose Open Folder in File Explorer from the shortcut menu to obtain the project path, for example, C:\Users\XXX\Documents\visual studio 2015\Projects\ConsoleApplication1\ConsoleApplication1.
  6. Copy the net35 file in the decompressed SDK package to the project path.
  7. Copy the dis.properties and version.properties files under the config directory from the decompressed SDK package to the $project path\bin\Debug directory.
  8. Modify the dis.properties file. For details about how to configure the values of endpoint, ak, sk, region, and projectId in this file, see Obtaining Authentication Information.

    IS_DEFAULT_TRUSTED_JKS_ENABLED=false
    data.encrypt.enabled=false
    
    #todo
    endpoint=https://yourdomainname
    region=Provide your region
    ak=Provide your Access Key
    sk=Provide your Secret Key
    projectId=Provide your project Id

  9. Use the Program.cs file under the demo folder in the decompressed SDK package to replace the corresponding file in the $project path directory.
  10. In Visual Studio, right-click References under the new project and choose Add Reference from the shortcut menu.

    Figure 3 Adding references

  11. In the Reference Manager dialog box, click Browse and select the following files in $project path\net35:

    DISClient_3._5.dll, DISCommon.dll, and Newtonsoft.Json.dll

    Figure 4 Adding dependency file *.dll

  12. Click OK.