# C# examples issues

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157>\
**Category:** Uncategorized\
**Created:** [December 9, 2025, 6:15pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157 "2025-12-09T18:15:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![evilC](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/evilc/32/711_2.png) [@evilC](https://rpi-rgb-led-matrix.discourse.group/u/evilC)\
**Post date:** [December 9, 2025, 6:15pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/1 "2025-12-09T18:15:51Z")

</div>

I see some changes were made recently to the C# bindings, but I still can’t get the PlayGif example to run.

There are issues with some of the others, but I managed to work around them. I thought I would post here rather than making a GitHub issue, as I guess it is probably known (Or it could just be an issue my end). Here is what works and what doesn’t:

- BoxesBoxesBoxes - works
- FontExample - not tried
- MatrixRain - missing `System.Threading`  
This seems to be due to the `Console.CancelKeyPress`code -if I comment that out, it works
- MinimalExample - works
- PlayGIF - missing `System.Collections.Concurrent`
- PulsingBrightness - missing `System.Threading` (as per MatrixRain)  
Otherwise works
- Rotating3DCube - missing `System.Threading` (as per MatrixRain)  
inconsistent variable name - `leds` rather than `matrix` as other examples use  
Otherwise works

The only one I really care about though is PlayGif - would love to see this working.

I am mainly curious if it will play a stream (As created with the `-O` flag of the `led-image-viewer` util), or could easily be modified to do so.

---

<div class="post-metadata">

**Author:** ![marcmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/marcmerlin/32/40_2.png) [@marcmerlin](https://rpi-rgb-led-matrix.discourse.group/u/marcmerlin)\
**Post date:** [December 15, 2025, 6:59am UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/3 "2025-12-15T06:59:25Z")

</div>

Please have a look at [Master Bug: C# (used to track C# PRs and issues) · Issue #1828 · hzeller/rpi-rgb-led-matrix · GitHub](https://github.com/hzeller/rpi-rgb-led-matrix/issues/1828) which talks about recent C# changes and needs.  
Long story short, it needs patches from C# users, so feel free to contribute

---

<div class="post-metadata">

**Author:** ![evilC](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/evilc/32/711_2.png) [@evilC](https://rpi-rgb-led-matrix.discourse.group/u/evilC)\
**Post date:** [December 15, 2025, 7:46pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/4 "2025-12-15T19:46:18Z")

</div>

OK, so I made some progress on this, I did make some [comments](https://github.com/hzeller/rpi-rgb-led-matrix/issues/1828#issuecomment-3656893339) on the issue, but I am wary of spamming the issue, so I will post here.

TLDR, it seems like the reason that some of the examples are giving a `FileNotFoundException` (eg for `System.Collections.Concurrent`), even though the required DLLs are in the folder is that the library is dropping privs

I was running as root.

I just tried switching to a non-root user (`dietpi`), but `dotnet` was installed as root, so `dietpi` could not run it.

So I tried logging in as dietpi instad, re-installing dotnet (it was installed as root), re-building the library, and trying again, and still the same issue.

However, I did set up dotnet as a “global” install - one copy in `/usr/local/share/dotnet`and configured things such that `dietpi` could access this one copy of dotnet.

I am wondering if that is maybe the issue, but at this point I have been trying to fix this for 10 hours when I could have been coding, and I am a bit demoralized.

Can anyone maybe try and see if they get the same issue with PlayGif? Curious if it’s just me.

---

<div class="post-metadata">

**Author:** ![evilC](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/evilc/32/711_2.png) [@evilC](https://rpi-rgb-led-matrix.discourse.group/u/evilC)\
**Post date:** [December 16, 2025, 4:49am UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/6 "2025-12-16T04:49:57Z")

</div>

Root AND sudo? Hadn’t tried that.

I just did, and it does not fix the problem with the C# PlayGif example.

Has anyone else gotten the C# PlayGif example to work?

Does anyone know if it is possible via the C# bindings to set the `--led-no-drop-privs` option? I think this not being set is what is causing the issue.

I spent 8 hours with AI and it could not work it out.

Obviously it would be utterly clueless to the fact that privs are being dropped.

---

<div class="post-metadata">

**Author:** ![evilC](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/evilc/32/711_2.png) [@evilC](https://rpi-rgb-led-matrix.discourse.group/u/evilC)\
**Post date:** [December 16, 2025, 5:07am UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/7 "2025-12-16T05:07:34Z")

</div>

I used AI to show me how to log the privs:

```auto
UserLogger.LogUser("Before maxtrix initialization:");
using var matrix = new RGBLedMatrix(32, 2, 1);
UserLogger.LogUser("After maxtrix initialization:");

```

Result:

```auto
root@DietPi:~/rpi-rgb-led-matrix/bindings/c#/examples/PlayGIF/bin/Debug/net8.0/linux-arm64/publish# sudo ./PlayGIF
Before maxtrix initialization:: User=root, UID=0, EUID=0
Suggestion: to slightly improve display update, add
        isolcpus=3
at the end of /boot/cmdline.txt and reboot (see README.md)
After maxtrix initialization:: User=daemon, UID=1, EUID=1
Unhandled exception. System.TypeInitializationException: The type initializer for 'SixLabors.ImageSharp.Configuration' threw an exception.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Concurrent, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

```

It’s defo dropping privs

---

<div class="post-metadata">

**Author:** ![evilC](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/evilc/32/711_2.png) [@evilC](https://rpi-rgb-led-matrix.discourse.group/u/evilC)\
**Post date:** [December 16, 2025, 6:06am UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/8 "2025-12-16T06:06:17Z")

</div>

SUCCESS!!!

I created a new copy of the library in `/home/deamon`, rebuilt, chowned everything in that path to `daemon` and the PlayGif C# sample works!!

So, it’s true, the privs are breaking it.

---

<div class="post-metadata">

**Author:** ![evilC](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/evilc/32/711_2.png) [@evilC](https://rpi-rgb-led-matrix.discourse.group/u/evilC)\
**Post date:** [December 16, 2025, 6:55am UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/9 "2025-12-16T06:55:22Z")

</div>

Hmm, after all this, seems like I maybe am a dummy… You do seem to be able to pass `--led-no-drop-privs'` to PlayGif???

I swear I tried it before…

---

<div class="post-metadata">

**Author:** ![evilC](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/evilc/32/711_2.png) [@evilC](https://rpi-rgb-led-matrix.discourse.group/u/evilC)\
**Post date:** [December 20, 2025, 7:15am UTC](https://rpi-rgb-led-matrix.discourse.group/t/c-examples-issues/1157/11 "2025-12-20T07:15:12Z")

</div>

> [@deadlift89](#):
>
> `--led-no-drop-privs` is a universal option. All flags prefixed with `--led` are. As long as the program is internally calling `rgb_matrix::ParseOptionsFromFlags` within the executional pathway, it should be supported by all programs including C# samples. That happens in most programs at the top of the main method when they instantiate RGBMatrix and Canvas objects.

I am not quite sure what you are saying here - is this currently supported via the bindings?

And is this still not only allowing you to set this option via command-line arguments?

IMHO, there needs to be a way to control this without having to pass command-line arguments.
