Running CVB in Linux using .NET Core

Hi,

I’m trying to run CVB on ubuntu-18.04 x64 using the .net core CVB api.

I have downloaded cvb-13.03.000-ubu1804-x86_64, run the installer and created a simple hello world application using the CVMock.vin driver.

My code looks like this:

using System;
using System.IO;
using Stemmer.Cvb;
using Stemmer.Cvb.Driver; // for IndexedStream
using Stemmer.Cvb.Utilities; // for SystemInfo

namespace Cvb
{
	class Program
	{
		static void Main(string[] args)
		{
			Example();
		}

		private static void Example() {
			Device device = DeviceFactory.OpenPort(@"/opt/cvb/drivers/CVMock.vin", 0);
			var stream = device.Stream;
			stream.Start();

			for (int i = 0; i < 100; i++) {
				var result = stream.Wait();
				var image = result;
				Console.WriteLine("timestamp: " + image.RawTimestamp);
			}
		}
	}
}

Then I publish this project as follows: dotnet publish -c release -r ubuntu.18.04-x64

When I run the binary I receive the following exception: Unhandled Exception: System.IO.FileLoadException: Loading the Device from file /opt/cvb/drivers/CVMock.vin failed.

This seems to be a .net core related issue as the C++ and Python examples do work.

Also I have gone through all steps described in this post where CVB is setup in a ubuntu:18.04 container, except for running it in a container (I’ve tried a regular Ubuntu setup and WSL2) with similar result.

Is there anything fundamental going on with CVB and .NET Core support or are there some different steps I need to take to get .NET Core compiled binaries to use CVB drivers?

Hi @gajus,

have you tried using the Open()?
Device device = DeviceFactory.Open(“CVMock.vin”)

Maybe you have to pass the whole path…

Hi @Chris, thanks for your reply.

When I try:

Device device = DeviceFactory.Open(@"/opt/cvb/drivers/CVMock.vin");

I get:

Unhandled Exception: System.IO.FileLoadException: Loading the Device from file /opt/cvb/drivers/CVMock.vin failed

This is the output of ls:

    $ ls /opt/cvb/drivers/
CVMock.vin    CVMock.vin.1.100      GenICam.vin    GenICam.vin.3.2       genicam
CVMock.vin.1  CVMock.vin.1.100.224  GenICam.vin.3  GenICam.vin.3.2.1410

The path seems valid, any other idea’s?

Usually this error occurs when either the driver is already in use, not found or there is a 32/64 bit missmatch between Cvb/Build of Application and the Os…

Hi, I build using:

dotnet publish -c release -r ubuntu.18.04-x64

This is the arch I’m running on:

	uname -a
Linux 4.4.0-19041-Microsoft #488-Microsoft Mon Sep 01 13:43:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux

I cant imagine the (Mock) driver is already in use, I just installed CVB yesterday on WSL2 and tried to get this test code working after that

@c.hartmann
any ideas on this would be appreciated :slight_smile:

ps this code runs fine on windows

Hi @gajus,

some general infos.

  • Running Cvb within Wsl1/2 works (with some restrictions), but it is not officially tested.
  • Running Cvb within a container is not officially tested.
  • Running Cvb .Net Core on Linux is not officially tested.

So building an application, with all (or just some of) the points above, might be a bit tricky.

However my assumption is that the “dotnet publish …” is the issue here. Specifically the dependencies.

As a next step i would suggest:

  1. create a log using LogGUI (or on WSL with siLogSvc -x (just because Wsl will create issues with UI)). With LogGUI you can set the logging levels (with Wsl you need to manipulate /var/opt/cvb/log/LogModuleConf.json).

LogModuleConf.json.zip (335 Bytes)

  1. Get in contact with de.support@stemmer-imaging.com (inspecting log files via the forum is not ideal). Just reference me in the email.

Hi @c.hartmann, assuming the logs are output by siLogSvc not much is turning up there when in run my binary.

	*****************************************************************
				  (c) 2015 STEMMER IMAGING GmbH
*****************************************************************

STEMMER IMAGING Logging Service Application
BuildDate :     Nov 11 2020


Running as LogSvc as Application

I have used the LogModuleConf.json as provided. I have looked extensively in various log directories but havent found any other cvb logs

Perhaps interesting to mention, last week we did some similar efforts in Ubuntu and ran LogGUI, also then no logs turned up.

In VS2019, this is my publish profile

Hi,

  1. Regarding the siLogSvc, it should have logged a lot of messages, is there by any chance an instance running a service?
  2. Regarding no logging on Ubuntu. Is this also the case, when just starting the genicambrowser?
  3. Regarding the publishing, I can already tell you that “Any CPU” is bad, definitly 64 or 32 bit (corresponding to your CVB installation). However i have to ask a collegue whether this has any chance of working.

https://forum.commonvisionblox.com/t/is-it-possible-to-run-a-c-application-with-mono/754/2

@gajus Ok this is the info i was looking, so a 32 bit setup (on either side) has higher, but unknown chance of working. But a 64bit setup will not work (with all released versions of cvb).