Index: System.Data.SQLite/UnsafeNativeMethods.cs
==================================================================
--- System.Data.SQLite/UnsafeNativeMethods.cs
+++ System.Data.SQLite/UnsafeNativeMethods.cs
@@ -691,15 +691,37 @@
///
private static string cachedAssemblyDirectory;
/////////////////////////////////////////////////////////////////////////
///
+ /// When this field is non-zero, it indicates the
+ /// method was not able to locate a
+ /// suitable assembly directory. The
+ /// method will check this
+ /// field and skips calls into the
+ /// method whenever it is non-zero.
+ ///
+ private static bool noAssemblyDirectory;
+
+ /////////////////////////////////////////////////////////////////////////
+ ///
/// This is the cached return value from the
/// method -OR- null if that method
/// has never returned a valid value.
///
private static string cachedXmlConfigFileName;
+
+ /////////////////////////////////////////////////////////////////////////
+ ///
+ /// When this field is non-zero, it indicates the
+ /// method was not able to locate a
+ /// suitable XML configuration file name. The
+ /// method will check this
+ /// field and skips calls into the
+ /// method whenever it is non-zero.
+ ///
+ private static bool noXmlConfigFileName;
#endregion
/////////////////////////////////////////////////////////////////////////
///
/// For now, this method simply calls the Initialize method.
@@ -847,10 +869,11 @@
#endregion
lock (staticSyncRoot)
{
cachedXmlConfigFileName = null;
+ noXmlConfigFileName = false;
}
}
/////////////////////////////////////////////////////////////////////////
///
@@ -874,10 +897,13 @@
lock (staticSyncRoot)
{
if (cachedXmlConfigFileName != null)
return cachedXmlConfigFileName;
+
+ if (noXmlConfigFileName)
+ return null;
}
return GetXmlConfigFileName();
}
@@ -926,10 +952,15 @@
cachedXmlConfigFileName = fileName;
}
return fileName;
}
+
+ lock (staticSyncRoot)
+ {
+ noXmlConfigFileName = true;
+ }
return null;
}
/////////////////////////////////////////////////////////////////////////
@@ -1594,10 +1625,11 @@
#endregion
lock (staticSyncRoot)
{
cachedAssemblyDirectory = null;
+ noAssemblyDirectory = false;
}
}
/////////////////////////////////////////////////////////////////////////
///
@@ -1620,10 +1652,13 @@
lock (staticSyncRoot)
{
if (cachedAssemblyDirectory != null)
return cachedAssemblyDirectory;
+
+ if (noAssemblyDirectory)
+ return null;
}
return GetAssemblyDirectory();
}
@@ -1647,33 +1682,61 @@
try
{
Assembly assembly = Assembly.GetExecutingAssembly();
if (assembly == null)
+ {
+ lock (staticSyncRoot)
+ {
+ noAssemblyDirectory = true;
+ }
+
return null;
+ }
string fileName = null;
#if PLATFORM_COMPACTFRAMEWORK
AssemblyName assemblyName = assembly.GetName();
if (assemblyName == null)
+ {
+ lock (staticSyncRoot)
+ {
+ noAssemblyDirectory = true;
+ }
+
return null;
+ }
fileName = assemblyName.CodeBase;
#else
if (!CheckAssemblyCodeBase(assembly, ref fileName))
fileName = assembly.Location;
#endif
if (String.IsNullOrEmpty(fileName))
+ {
+ lock (staticSyncRoot)
+ {
+ noAssemblyDirectory = true;
+ }
+
return null;
+ }
string directory = Path.GetDirectoryName(fileName);
if (String.IsNullOrEmpty(directory))
+ {
+ lock (staticSyncRoot)
+ {
+ noAssemblyDirectory = true;
+ }
+
return null;
+ }
lock (staticSyncRoot)
{
cachedAssemblyDirectory = directory;
}
@@ -1698,10 +1761,15 @@
{
// do nothing.
}
#endif
}
+
+ lock (staticSyncRoot)
+ {
+ noAssemblyDirectory = true;
+ }
return null;
}
#endregion