I find that Managed ODP.Net cannot work with windows path containning non-ascii characters. When I was trying to connect to oracle database using Oracle.ManagedDataAccess.dll from a location with non-ascii characters in its path, I got a System.IndexOutOfRangeException. Via RedGate .Net Reflector, I caught the source error line.
The error source:
OracleInternal.Network.AddressResolution.VetCIDValue(string CIDValue) //The value of CIDValue is @"E:\\Documents\\2014\\GpsMidware\\svn代码
//\\map_gps\\WcfService\\bin\\Debug\\GpsMidwareService.vshost.exe"
{
StringBuilder builder;
try
{
builder = new StringBuilder(CIDValue);
for (int i = 0; i < builder.Length; i++)
{
if (ValidChars[builder[i]] == 0) //This is where the exception is thrown. The length of the array ValidChars is only 256,
//and the value of builder[i] is its unicode value, so if the path contains any non-ascii
//character, then the index will be out of range!!!
{
builder[i] = '?';
}
}
}
catch (Exception)
{
return "";
}
return builder.ToString();
}
The production version of Oracle.ManagedDataAccess.dll is 4.121.1.0, the file version is 4.121.1.20131211, coming from
----------------------------------------------------------------------------------------------------
The call stack:
| > | Oracle.ManagedDataAccess.dll!OracleInternal.Network.AddressResolution.VetCIDValue(string CIDValue) Line 645 | C# |
| Oracle.ManagedDataAccess.dll!OracleInternal.Network.AddressResolution.AddressResolution() Line 166 | C# |
| [Native to Managed Transition] | |
| Oracle.ManagedDataAccess.dll!OracleInternal.Network.OracleCommunication.Resolve(string tnsAlias) Line 247 | C# |
| Oracle.ManagedDataAccess.dll!OracleInternal.ConnectionPool.PoolManager<OracleInternal.ConnectionPool.OraclePoolManager,OracleInternal.ConnectionPool.OraclePool,OracleInternal.ServiceObjects.OracleConnectionImpl>.Initialize(Oracle.ManagedDataAccess.Client.ConnectionString cs) Line 1565 | C# |
| Oracle.ManagedDataAccess.dll!OracleInternal.ConnectionPool.OraclePoolManager.Initialize(Oracle.ManagedDataAccess.Client.ConnectionString cs) Line 258 | C# |
| Oracle.ManagedDataAccess.dll!OracleInternal.ConnectionPool.OracleConnectionDispenser<OracleInternal.ConnectionPool.OraclePoolManager,OracleInternal.ConnectionPool.OraclePool,OracleInternal.ServiceObjects.OracleConnectionImpl>.GetPM(Oracle.ManagedDataAccess.Client.ConnectionString cs, OracleInternal.ConnectionPool.OraclePoolManager conPM, Oracle.ManagedDataAccess.Client.ConnectionString pmCS, System.Security.SecureString securedPassword, System.Security.SecureString securedProxyPassword, out bool bAuthenticated, out bool newPM) Line 484 | C# |
| Oracle.ManagedDataAccess.dll!OracleInternal.ConnectionPool.OracleConnectionDispenser<OracleInternal.ConnectionPool.OraclePoolManager,OracleInternal.ConnectionPool.OraclePool,OracleInternal.ServiceObjects.OracleConnectionImpl>.Get(Oracle.ManagedDataAccess.Client.ConnectionString cs, OracleInternal.ConnectionPool.OraclePoolManager conPM, Oracle.ManagedDataAccess.Client.ConnectionString pmCS, System.Security.SecureString securedPassword, System.Security.SecureString securedProxyPassword) Line 298 | C# |
| Oracle.ManagedDataAccess.dll!Oracle.ManagedDataAccess.Client.OracleConnection.Open() Line 1308 | C# |
| DBUtility.dll!DBUtility.OracleHelper.PrepareCommand(System.Data.Common.DbCommand cmd, System.Data.Common.DbConnection conn, System.Data.Common.DbTransaction trans, System.Data.CommandType cmdType, string cmdText, System.Data.Common.DbParameter[] cmdParms) Line 238 | C# |
| DBUtility.dll!DBUtility.OracleHelper.ExecuteReader(string connectionString, System.Data.CommandType cmdType, string cmdText, System.Data.Common.DbParameter[] cmdParms) Line 155 | C# |
| DBUtility.dll!DBUtility.DBHelper.ExecuteReader(System.Data.CommandType cmdType, string cmdText, System.Data.Common.DbParameter[] cmdParms) Line 293 | C# |
| DAL.dll!DAL.CARRELATEEQUIPMENT.GetModelByEQUIPMENTID(string eQUIPMENTID) Line 118 | C# |
| BLL.dll!BLL.CARRELATEEQUIPMENT.GetModelByEQUIPMENTID(string eQUIPMENTID) Line 118 | C# |
| GpsMidwareService.exe!GpsMidwareService.GpsTerminalManager.ReadGPSNetFileData(object parameters) Line 880 | C# |
| mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) | Unknown |
| mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) | Unknown |
| mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) | Unknown |
| mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) | Unknown |
| mscorlib.dll!System.Threading.ThreadHelper.ThreadStart(object obj) | Unknown |