Question:
I use System.Data.OracleClient.
System.Data.OracleClient requires OracleInstantClient, which are native dll's. So in order to use System.Data.OracleClient, I need the native dll's installed, or in a folder in the path environment variable.
Now, the base problem is, I don't have administrator rights (company laptop - corporate stupidity - not going to change)...
So I can neither install anything, nor copy anything in a folder in PATH, nor can I add a folder to the path environment variable, nor can I restart/administer IIS or any other service...
So as a test, I just copied oci.dll and oraociei11.dll into the same folder as the WinForms .exe.
This worked fine. I was able to access the Oracle database (SELECT * FROM COUNTRIES) without problems.
But now, I need to perform the same query in an ASP.NET solution. The problem is, ASP.NET dll's get shadow copied to a temporary folder when they execute.
Now to get the dll's to the webapp bin non-the-less,
in Global.asax in
public class MvcApplication : System.Web.HttpApplication
I overwrote Init with this:
public override void Init()
{
int iBitNess = IntPtr.Size;
//System.Windows.Forms.MessageBox.Show(iBitNess.ToString());
// iBitNess = 4, so 32 bit dll's are right
string strTargetDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;
strTargetDirectory = typeof(DB.Abstraction.cDAL).Assembly.Location;
strTargetDirectory = typeof(MvcApplication).Assembly.Location;
strTargetDirectory = System.IO.Path.GetDirectoryName(strTargetDirectory);
string strSourcePath = Server.MapPath("~/bin/dependencies/InstantClient");
string[] astrAllFiles = System.IO.Directory.GetFiles(strSourcePath, "*.dll");
foreach (string strSourceFile in astrAllFiles)
{
string strTargetFile = System.IO.Path.GetFileName(strSourceFile);
strTargetFile = System.IO.Path.Combine(strTargetDirectory, strTargetFile);
System.IO.File.Copy(strSourceFile, strTargetFile);
}
base.Init();
} // End Sub Init
in order to copy the native dll's to the supposedly correct location. But I still get DllNotFound Exception...
Where or how do I have to put a native dll in a ASP.NET application ?
I say again: I cannot set environment variables, and I cannot copy the dlls to a folder that is in path. (which would normally solve the problem).
As you see with the multiple occurences of
strTargetDirectory =
I tried several possibilites, none of which worked.