So I cannot find a solution to this problem: I am using a .DLL Library which I need to interact with an external device, but when I'm using the .DLL (bold line in code example) I get the error: system.typeinitializationexception' occurred in mscorlib.dll
The .DLL should be correctly implemented through properties in the solution explorer of Visual Studio 2015 and the code works with no problem on 2 different laptops, but this error occurs when I try to use it on my desktop - where I need it to be functional.
Code example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Inomed;
using Inomed.Software.CommonLib.NeurostimInterface;
namespace Server3
{
static class Program
{
**public static Neurostim_interface myNeuro = new Neurostim_interface();**
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Error:
An unhandled exception of type 'System.TypeInitializationException' occurred in mscorlib.dll
Additional information:
The type initializer for 'Server3.Program' threw an exception. Debug: [...] 'Server3.vshost.exe' (CLR v4.0.30319: Server3.vshost.exe): Loaded 'c:\users\bo\documents\visual studio 2015\Projects\Server3\Server3\bin\Debug\Neurostimulator_HID_DLL.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Exception thrown: 'System.Runtime.InteropServices.COMException' in Neurostimulator_HID_DLL.dll The program '[11160] Server3.vshost.exe' has exited with code 0 (0x0).