- Home /
Connecting to SQL database from iOS app made by Unity fail with error
I try to store app usage log on SQL database of Azure.
My iOS app show an error when it connects to SQL server while debugging with Xcode and on iPad.
I bring System.Data.dll from Contents/MonoBleedingEdge/lib/mono/unityjit
since without this, using System.Data.SqlClient;
showed error.
Build on Unity and build and run on Xcode succeeded. When I call the function on iPad, the error appeared and cannot add record on database.
It seems like an error is caused by the following function since without this, the error disappear. Reading the error message, it looks some function I used is not available for il2cpp build but not sure how to cope with this error. Could you tell me how to debug this error?
Thanks.
script:
using UnityEngine;
using System.Data.SqlClient;
public class LogDBCall : MonoBehaviour {
public void InsertRecord(string person_name, string device_id)
{
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = <server>;
builder.UserID = <userid>;
builder.Password = <password>;
builder.InitialCatalog = <database>;
SqlConnection connection = new SqlConnection(builder.ConnectionString);
connection.Open();
var command = new SqlCommand();
command.Connection = connection;
command.CommandText = @"INSERT INTO db_name(person_name, device_id ) VALUES
('"+person_name+"','"+device_id+"' );";
command.ExecuteNonQuery();
connection.Close();
}
}
error Log:
LogDBCall:InsertRecord(String, String, Int32, String)
<Register>c__Iterator1:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
NotSupportedException: /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection/Assembly.cpp(547) : Unsupported internal call for IL2CPP:Assembly::GetManifestModuleInternal - "This icall is not supported by il2cpp."
at Bid.initEntryPoint () [0x00000] in <00000000000000000000000000000000>:0
at Bid+AutoInit..ctor () [0x00000] in <00000000000000000000000000000000>:0
at Bid.internalInitialize () [0x00000] in <00000000000000000000000000000000>:0
at Bid..cctor () [0x00000] in <00000000000000000000000000000000>:0
at System.Data.Common.DbConnectionStringBuilder.get_ConnectionString () [0x00000] in <00000000000000000000000000000000>:0
at LogDBCall.InsertRecord (System.String person_name, System.String device_id) [0x00000] in <00000000000000000000000000000000>:0
at Registration+<Register>c__Iterator1.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TypeInitializationException: The type initializer for 'Bid' threw an exception.
at System.Data.Common.DbConnectionStringBuilder.get_ConnectionString () [0x00000] in <00000000000000000000000000000000>:0
at LogDBCall.InsertRecord (System.String person_name, System.String device_id) [0x00000] in <00000000000000000000000000000000>:0
at Registration+<Register>c__Iterator1.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
My environment:
Unity version 2017.4 LTS and 2018.4 LTS Macbook Pro version 10.14.5 Xcode version 10.2.1(10E1001) iPad Pro 12.9 inch 3rd generation Configuration: .NET 4.x Equivalent IL2CPP .NET 4.x