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 File → New → Project…. Choose Console App for Visual C#.
Then, add your project name, location, and .NET version. In this tutorial, we will use the following file name and location:
Location |
|
C# file name |
|
.NET version |
|
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 Add → Project Reference… → Browse.
Navigate to C:Program FilesZividbin
and add ZividCoreNET.dll and ZividVisualizationNET.dll.
Select the correct platform target
Right click on your project again, then click Properties.
Under Build → General, change Platform target to x64
.
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
Run the program
Now we have set up and configured everything. Run the program by pressing F5 key.
Zivid 및 C#에서 개발을 계속하려면 다음 페이지의 Zivid .NET API reference 및 Build C# Samples using Visual Studio 튜토리얼을 확인하십시오.
Version History
SDK |
Changes |
---|---|
2.12.0 |
Remove support for Visual Studio 2017. |