sta / websocket-sharp

A C# implementation of the WebSocket protocol client and server
http://sta.github.io/websocket-sharp
MIT License
5.66k stars 1.65k forks source link

ExecutionEngineException in Unity app iOS #104

Open ignacioa opened 9 years ago

ignacioa commented 9 years ago

I get this error:

ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-native) System.Threading.Interlocked:CompareExchange (System.EventHandler1&,System.EventHandler1,System.EventHandler`1)' while running with --aot-only.

at WebSocketSharp.WebSocket.add_OnMessage (System.EventHandler`1 value) [0x00000] in :0

This happens while running on a iOS device. I haven't been able to try it on Android yet. Webplayer appears to be unaffected. I've built the .dll myself using the bundled MonoDevelop with Unity 4.6.2.

This is the code that appears to be causing the error:

public WebSocket ws = null;
void Awake () {     
    if(!Security.PrefetchSocketPolicy(getIP(Host), SocketCrossdomainPort)) {
        Debug.Log(this,"Error fetching policies. You must have running the unity socket crossdomain server.");
    }

    ws = new WebSocket ("ws://" + Host + ":" + DominionServerPort);
    ws.OnMessage += OnMessage;
    ws.OnError += OnError;
    ws.OnClose += OnClose;  

}

Any help would be appreciated.

mayflaver commented 9 years ago

I get this error, alse, help!!!

mayflaver commented 9 years ago

source instead of dll, it's ok.

sta commented 9 years ago

Hello there,

@ignacioa Could you use an older MonoDevelop, such as bundled with Unity 4.3?

ignacioa commented 9 years ago

I've build the library with the Monodevelop bundled with 4.3, I still get the error. I had to switch back to 4.6.2 since my game uses features that are not present in 4.3

I noticed that the monodevelop versions in 4.6.2 and 4.3 appear to be the same though (4.0.1). Is this correct?

sta commented 9 years ago

Hmm,,, Didn't you change the target framework?

ignacioa commented 9 years ago

No, do you mean the .NET Runtime in the MonoDevelop preferences?

This is all I see on the 4.3 Bundled MonoDevelop preferences:

http://i.imgur.com/IyRMCpN.png

Bear in mind that this is a parallel installation to the 4.6.2 version and that I'm on the mac OS.

Is this what you mean?

sta commented 9 years ago

Nope. I mean "which .NET Framework (3.5 or other) did you use in building websocket-sharp? (Didn't you change the target framework from 3.5?)". I guess that error is due to building with later than 3.5.

And, could you use something decompile tool (such as ILSpy)?, and describe how was that part of websocket-sharp (WebSocket.OnMessage event) compiled in your environment?

ignacioa commented 9 years ago

Ok I've compiled the library using Visual Studio 2008 and using the 3.5 NET Framework and the errors went away!

sta commented 9 years ago

Hmm,,, ".NET Framework (target framework)" that i mean is "Select websocket-sharp project > Select Project/websocket-sharp Options from menu bar > Target framework in Build/General on Project Options window", in MonoDevelop.

So, you don't need such old Visual Studio, and i guess you can compile it (same as VS) with MonoDevelop on your mac OS.

madebysoren commented 9 years ago

@mayflaver - where do you get the source from? I bought the asset on Asset Store and imported it, but only the dll (no source files included). Att: @sta .