Lupu Silviu Lupu Silviu - 8 months ago 110
C# Question

Affectiva C# SDK crashes

I just started using Affectiva SDK for C#, and after a few runs, I stumbled upon a continuous crash problem.
I am using the Camera processing, on x86 architecture and .Net 4.5.1. I have VS 2013 installed. My OS is Windows 10. I have added "opencv_ffmpeg248" and "affdex-native" in my output.
The code builds and runs ok, but from time to time, during runtime, it throws this errors and the application closes.

This is the code that I am using:

public class Class1 : Affdex.ImageListener
private Affdex.CameraDetector _detector;

public event EventHandler<string[]> AllValuesEvent;

public Class1()
_detector = new Affdex.CameraDetector();

String classifierPath = @"C:\Program Files (x86)\Affectiva\Affdex SDK\data";

public void StopCamera()

public void onImageCapture(Frame frame)


public void onImageResults(Dictionary<int, Face> faces, Frame frame)
if (faces.Count > 0)
Face face = faces.First().Value;

Console.WriteLine("Age: {0} Gender: {1} Glasses: {2}",

string[] names = new string[8];
string[] values = new string[8];

names[0] = "Anger";
names[1] = "Contempt";
names[2] = "Disgust";
names[3] = "Engagement";
names[4] = "Fear";
names[5] = "Joy";
names[6] = "Sadness";
names[7] = "Surprise";

values[0] = face.Emotions.Anger.ToString("F2");
values[1] = face.Emotions.Contempt.ToString("F2");
values[2] = face.Emotions.Disgust.ToString("F2");
values[3] = face.Emotions.Engagement.ToString("F2");
values[4] = face.Emotions.Fear.ToString("F2");
values[5] = face.Emotions.Joy.ToString("F2");
values[6] = face.Emotions.Sadness.ToString("F2");
values[7] = face.Emotions.Surprise.ToString("F2");

RaiseAllValuesEvent(names, values);

private void RaiseAllValuesEvent(string[] names, string[] values)
if (AllValuesEvent != null)
AllValuesEvent(names, values);

These are the errors that appear:
enter image description here
enter image description here

Anyone has any suggestions?

Thank you very much.


I am posting this here, to be able to mark as answer, and to have this topic closed.

As suggested by @ahamino in a comment, the issue was the fact that I have accidentally mixed debug dlls into my references. Adding only release dlls fixed my issue.

Thank you again @ahamino.