Unity Editor crashes when loading managed Plug-in (external DLL)

I am having this strange problem for a couple of weeks now and I tried a lot of different things that presumeably would fix the problem. But now I am at a loss.

Simply said I am making a 3D map application in Unity and I need to recieve external data over a WebSocket. So I have made a managed plug-in that references a WebSocket library for .Net (http://websocket4net.codeplex.com/). The plug-in itself contains a couple of classes that make a connection with the WebSocket through the WebSocket library and some datastructures for temporary storage. Once I load the plug-in and add the DLL including all the DLL’s that my plug-in references and I add a C# script in Unity to query some data by instantiating an object of a public class from the plug-in and run it, the Unity Editor crashes (freezes, process doesn’t respond anymore). Things I have already tried/done.

  1. My own plug-in is compiled against .Net 2.0 target with VS2013 compiler. The DLL’s my plug-in references are also compiled against .Net 2.0 target with VS compiler. I also tried compiling both in MonoDevelop against Mono / .Net 2.0 target but that didn’t fix the error.
  2. I added the UnityEngine DLL to my plug-in as a reference but not into the libraries my plug-in references.
  3. When I run a console application in MonoDevelop that uses my plug-in and it’s dependencies the application works and queries the data without crashing.
  4. The DLL’s have been configured in Unity for the right target both Editor and Standalone for Windows x86_x64 only.
  5. I am running Windows 7 SP1 x64, the Unity Editor is 64-bit (5.2.0f3) and all my DLL’s have been compiled to Any CPU (x86_x64). So no compatibility issues should arise there.

The only thing I could possibly think of is the following. According to this: http://jacksondunstan.com/articles/2949 article. Unity doesn’t work well with Events in managed plug-ins. In my plug-in I am using a AutoResetEvent that lets my WebSocket Get Data method wait until the connection is established and all data is recieved. Because the WebSocket pushes data continuously on update. Could this cause any problems inside Unity? For example a crash of the Editor because it runs the Editor and the plug-in in the same thread? Or because it thinks it’s unresponsive because the plug-in has to Wait in it’s own code?

Any guidance or help would be greatly appreciated! Because I am now at the point that i am thinking that this might not even be possible at all.

Hello! Do you find a solution to this problem? I have the same problem, and I couldn’t solve it yet.

Thank you!