本文使用的是oracle10g
按照常规把.NET Framework下的System.Data.dll,System.Data.OracleClient.dll复制粘贴到Assets目录下,VS添加引用。u3d调试运行报错如下:
Internal compiler error. See the console log for more information. outputwas: Unhandled Exception: System.IO.FileNotFoundException: Could not load fileor assembly 'System.EnterpriseServices, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
解决方案:不能使用.NET的Framework,必须使用mono定制的对应.NET Framework的dll。索引到:d:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0
添加该目录下的System.Data.dll,System.Data.OracleClient.dll替换上面的dll.
u3d调试运行,成功.
但是发布的时候不成功,并报错,说缺少相关dll,于是又在Mono目录下添加了提示的dll。成功运行。
添加的dll有:
本测试程序代码如下:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
public class OracleConnect : MonoBehaviour {
string connectStr = "DATA SOURCE=MXSHGC;USER ID=lwhouse;PASSWORD=wms;POOLING=FALSE;";
List
// Use this for initialization
void Start () {
using (OracleConnection aOracleConnection = new OracleConnection(connectStr))
}
void OnGUI()
{
if (listOfName.Count > 0)
{
GUI.Button(new Rect(50, 50, 100, 50), listOfName[0].ToString());
}
else
{
GUI.Button(new Rect(50, 50, 100, 50), "哈哈");
}
}
}