I am making a simple console program that checks if headphones are plugged in. There seems to be something wrong with the part where I created an object or instance of Microsoft.DirectX.DirectSound.Speakers called 'soundSpeakers'. I know this because if I take this part away the program doesn't crash.
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.DirectX.DirectSound;
namespace Headphone_detect
{
class Program
{
static void Main(string[] args)
{
bool checkHeadphone = true;
Speakers soundSpeakers = new Speakers();
Console.WriteLine("Created object");
while (checkHeadphone == true)
{
Console.WriteLine("While started");
if (soundSpeakers.Headphone == true)
{
Console.WriteLine("There are headphones plugged in.");
}
else
{
Console.WriteLine("There are no headphones plugged in.");
}
}
}
}
}
I have a bad feeling that I'm doing this completely wrong because when I google how to detect headphones plugged in every single post was seriously complex about how to solve it. Also, I have added a reference to Microsoft.DirectX.DirectSound in Visual Studio.
I forgot to mention that my error kid is as follows:
Unhandled Exception: System.IO.FileLoadException: Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. at Headphone_detect.Program.Main(String[] args)