DLLs not working on device(Working everywhere else)

HI guys, trying to use Google Docs with my unity3d application, the problem is that it just don’t work in iOS! It works on standalone, inside the editor and even works in the iOS Simulator, but if you build it and test on the device, it’ll not work.

The output of the error showed when you try to “login” is the following:

ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-native) System.Threading.Interlocked:CompareExchange (Google.GData.Client.ServiceEventHandler,Google.GData.Client.ServiceEventHandler,Google.GData.Client.ServiceEventHandler)' while running with --aot-only.

  at Google.GData.Client.Service.add_NewFeed (Google.GData.Client.ServiceEventHandler value) [0x00000] in <filename unknown>:0 
  at Google.GData.Spreadsheets.SpreadsheetsService..ctor (System.String applicationName) [0x00000] in <filename unknown>:0 
  at FirstTest.SetUp (System.String email, System.String password) [0x00000] in <filename unknown>:0 
  at FirstTest.OnGUI () [0x00000] in <filename unknown>:0 
 
(Filename:  Line: -1)

Here is the complete link to the project(9.5mb)
http://www.mediafire.com/?7388mm9oiq7ki23

The complete code:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Spreadsheets;

public class FirstTest : MonoBehaviour {
	
	public List<string> slist = new List<string>();
	public string mail = "";
	public string pass = "";
	void OnGUI()
	{	
		GUILayout.BeginHorizontal();
		GUILayout.Label("email: ");
		mail = GUILayout.TextArea(mail, GUILayout.Width(300));
		GUILayout.EndHorizontal();

		GUILayout.Space(30);

		GUILayout.BeginHorizontal();
		GUILayout.Label("pass: ");
		pass = GUILayout.TextArea(pass, GUILayout.Width(300));
		GUILayout.EndHorizontal();

		if(GUILayout.Button("Login"))
		{
			SetUp (mail, pass);
		}

		// Draw all spreadsheets
		PrintAllSpreadSheets();
	}

	public void SetUp(string email, string password)
	{
		// Connect to GDocs
		SpreadsheetsService myService = new SpreadsheetsService("exampleCo-exampleApp-1");
		myService.setUserCredentials(email, password);

		Debug.Log("Should be Connected");

		// Query for spreadsheets
		SpreadsheetQuery query = new SpreadsheetQuery();
		SpreadsheetFeed feed = myService.Query(query);
		
		Debug.Log("Your spreadsheets:");
		foreach (SpreadsheetEntry entry in feed.Entries)
		{
			Debug.Log(entry.Title.Text);
			slist.Add(entry.Title.Text);
		}
	}

	public void PrintAllSpreadSheets()
	{
		GUILayout.BeginVertical();
		foreach (string item in slist) 
		{
			GUILayout.Label(item);
		}
		GUILayout.EndVertical();
	}

}

It looks like the dll is a native dll. I.e it was written in c or C++. You would need to compile the dll for ios or get one already compiled for you.

K

The problem is that the JIT compiler is being invoked on iOS which is illegal. Unity applications for iOS use the Mono AOT compiler, where AOT means ‘Ahead of time’ so that the JIT compiler is not needed.

All issues I have ever seen with InterlockedExchange results from use of an external .NET assembly referenced from C# Unity Script that uses events without explicitly defining add/remove members.

For example:

public event EventHandler MyEvent ;

Instead you need the event coded as follows:

private EventHandler myEventListeners ;

public event EventHandler MyEvent {
add {
myEventListeners += value ;
}

remove {
myEventListners -=value ;
}
}

If you do not have the source for the assembly you are mostly out-of-luck.

There are a variety of reasons that the AOT compiler did not handle this, all beyond the scope of this thread.

The DLLs were compiled by myself using MonoDevelop, the only one I didn’t compiled was one that was missing in the Google API project, some JSON library called Newtonsoft.Json.dll, I’ve picked the mobile version of this DLL, do you think that compiling it by myself can solve the problem?

Also, inside unity the API compatibility level must be set to .Net 2.0, if not the AOT compilation in the final build step(inside unity) will fail.

As long as you change the event declaration(s) as I suggested it should work. You are using code that requires a “fuller” version of .NET than the ‘Subset’ If that is an issue, you need to take a hard look at your dependencies and see if you can eliminate some of them.