Build a C# “Zivid Hello World” Application in Visual Studio on Windows

This tutorial shows how to create and develop a C# application with Zivid in Visual Studio 2022. Note that the steps may vary slightly for other versions of Visual Studio.

Requirements

참고

Zivid uses .NET framework version 4.5.2. For more information, see .NET framework version.

Instructions

Create a new project

Run Visual Studio, then click Create new project, or FileNewProject…. Choose Console App for Visual C#.

Visual Studio의 새 C# 프로젝트

Then, add your project name, location, and .NET version. In this tutorial, we will use the following file name and location:

Location

C:workZividHelloWorld

C# file name

ZividHelloWorld.cs

.NET version

.NET Framework 4.8.0

Visual Studio의 새 C# 프로젝트

Add the main C# code

Replace the code in ZividHelloWorld.cs with the following code snippet:

using System;

namespace ZividHelloWorld
{
    class ZividHelloWorld
    {
        static int Main()
        {
            try
            {
                var zivid = new Zivid.NET.Application();
                Console.WriteLine("Hello World!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return 1;
            }
            return 0;
        }
    }
}

Add reference to Zivid .NET API

We must add a reference to the Zivid .NET API to run the code sample. Right-click on your project in Solution Explorer, then click AddProject Reference…Browse. Navigate to C:Program FilesZividbin and add ZividCoreNET.dll and ZividVisualizationNET.dll.

Visual Studio의 .NET 참조 관리자

Select the correct platform target

Right click on your project again, then click Properties. Under BuildGeneral, change Platform target to x64.

Visual Studio의 플랫폼 대상

Add post-build event command line code

In the same Build page, under Events, add the following code block to the Post-build event event command line:

if $(ConfigurationName) == Debug GOTO Debug
if $(ConfigurationName) == Release GOTO Release
goto Error

:Debug
xcopy "$(ZIVID_INSTALL_FOLDER)\bin_debug\*.dll" "$(TargetDir)" /Y
exit /B 0

:Release
xcopy "$(ZIVID_INSTALL_FOLDER)\bin\*.dll" "$(TargetDir)" /Y
exit /B 0
:Error
echo Unsupported config
exit /B 1
Visual Studio의 플랫폼 대상

Run the program

Now we have set up and configured everything. Run the program by pressing F5 key.

Screenshot of console output from program run from Visual Studio.

Zivid 및 C#에서 개발을 계속하려면 다음 페이지의 Zivid .NET API referenceBuild C# Samples using Visual Studio 튜토리얼을 확인하십시오.

Version History

SDK

Changes

2.12.0

Remove support for Visual Studio 2017.