# Running CVB in Linux using .NET Core

**URL:** <https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280>\
**Category:** .Net API\
**Created:** [December 1, 2020, 10:43am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280 "2020-12-01T10:43:09Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![gajus](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gajus](https://forum.commonvisionblox.com/u/gajus)\
**Post date:** [December 1, 2020, 10:43am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/1 "2020-12-01T10:43:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [December 2, 2020, 8:45am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/2 "2020-12-02T08:45:37Z")

</div>

Hi @gajus,

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

Maybe you have to pass the whole path…

---

<div class="post-metadata">

**Author:** ![gajus](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gajus](https://forum.commonvisionblox.com/u/gajus)\
**Post date:** [December 2, 2020, 9:02am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/3 "2020-12-02T09:02:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [December 2, 2020, 9:08am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/4 "2020-12-02T09:08:03Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![gajus](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gajus](https://forum.commonvisionblox.com/u/gajus)\
**Post date:** [December 2, 2020, 9:14am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/5 "2020-12-02T09:14:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [December 2, 2020, 9:25am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/6 "2020-12-02T09:25:37Z")

</div>

@c.hartmann  
any ideas on this would be appreciated 🙂

---

<div class="post-metadata">

**Author:** ![gajus](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gajus](https://forum.commonvisionblox.com/u/gajus)\
**Post date:** [December 2, 2020, 10:28am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/7 "2020-12-02T10:28:50Z")

</div>

ps this code runs fine on windows

---

<div class="post-metadata">

**Author:** ![c.hartmann](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/c.hartmann/32/247_2.png) [@c.hartmann](https://forum.commonvisionblox.com/u/c.hartmann)\
**Post date:** [December 3, 2020, 8:46am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/8 "2020-12-03T08:46:21Z")

</div>

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](https://forum.commonvisionblox.com/uploads/short-url/wOPOZcCm7IHKgBZd6RYyyPbHVP6.zip) (335 Bytes)

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

---

<div class="post-metadata">

**Author:** ![gajus](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gajus](https://forum.commonvisionblox.com/u/gajus)\
**Post date:** [December 3, 2020, 12:13pm UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/9 "2020-12-03T12:13:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gajus](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gajus](https://forum.commonvisionblox.com/u/gajus)\
**Post date:** [December 4, 2020, 7:13am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/10 "2020-12-04T07:13:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gajus](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gajus](https://forum.commonvisionblox.com/u/gajus)\
**Post date:** [December 4, 2020, 7:16am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/11 "2020-12-04T07:16:40Z")

</div>

In VS2019, this is my publish profile

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/0e77fe2a5c561405cae8d803e44a1d96b964aa7e.png)

---

<div class="post-metadata">

**Author:** ![c.hartmann](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/c.hartmann/32/247_2.png) [@c.hartmann](https://forum.commonvisionblox.com/u/c.hartmann)\
**Post date:** [December 8, 2020, 11:56am UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/12 "2020-12-08T11:56:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![c.hartmann](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/c.hartmann/32/247_2.png) [@c.hartmann](https://forum.commonvisionblox.com/u/c.hartmann)\
**Post date:** [December 8, 2020, 12:20pm UTC](https://forum.commonvisionblox.com/t/running-cvb-in-linux-using-net-core/1280/13 "2020-12-08T12:20:20Z")

</div>

[https://forum.commonvisionblox.com/t/is-it-possible-to-run-a-c-application-with-mono/754/2](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).
