Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7051237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:14:22+00:00 2026-05-28T03:14:22+00:00

Question: I use System.Data.OracleClient. System.Data.OracleClient requires OracleInstantClient, which are native dll’s. So in order

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:14:23+00:00Added an answer on May 28, 2026 at 3:14 am

    Solved.
    Apparently one still needs to load the native dll’s after copying them to the target folder.
    OnInit was incorrect, it’s for HTTP modules.
    We need to do this only once, hence moved to Application_Start.

    Here’s my code, in case anybody needs it:

       // Hinweis: Anweisungen zum Aktivieren des klassischen Modus von IIS6 oder IIS7 
        // finden Sie unter "http://go.microsoft.com/?LinkId=9394801".
        public class MvcApplication : System.Web.HttpApplication
        {
    
            [System.Runtime.InteropServices.DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
            static extern IntPtr LoadLibrary(string lpFileName);
    
            [System.Runtime.InteropServices.DllImport("kernel32", CharSet = System.Runtime.InteropServices.CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
            static extern UIntPtr GetProcAddress(IntPtr hModule, string procName);
    
            [System.Runtime.InteropServices.DllImport("kernel32", SetLastError = true)]
            [return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
            static extern bool FreeLibrary(IntPtr hModule);
    
    
            // See http://mpi4py.googlecode.com/svn/trunk/src/dynload.h
            const int RTLD_LAZY = 1; // for dlopen's flags
            const int RTLD_NOW = 2; // for dlopen's flags
    
            [System.Runtime.InteropServices.DllImport("libdl")]
            static extern IntPtr dlopen(string filename, int flags);
    
            [System.Runtime.InteropServices.DllImport("libdl")]
            static extern IntPtr dlsym(IntPtr handle, string symbol);
    
            [System.Runtime.InteropServices.DllImport("libdl")]
            static extern int dlclose(IntPtr handle);
    
            [System.Runtime.InteropServices.DllImport("libdl")]
            static extern string dlerror();
    
    
            public void LoadSharedObject(string strFileName)
            {
                IntPtr hSO = IntPtr.Zero;
    
                try
                {
    
                    if (Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        hSO = dlopen(strFileName, RTLD_NOW);
                    }
                    else
                    {
                        hSO = LoadLibrary(strFileName);
    
                    } // End if (Environment.OSVersion.Platform == PlatformID.Unix)
    
                } // End Try
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                } // End Catch
    
                if (hSO == IntPtr.Zero)
                {
                    throw new ApplicationException("Cannot open " + strFileName);
                } // End if (hExe == IntPtr.Zero)
    
            } // End Sub LoadSharedObject
    
    
            // http://stackoverflow.com/questions/281145/asp-net-hostingenvironment-shadowcopybinassemblies
            public void EnsureOracleDllsLoaded()
            {
                int iBitNess = IntPtr.Size * 8;
    
                string strTargetDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;
                strTargetDirectory = System.IO.Path.GetDirectoryName(strTargetDirectory);
    
                string strSourcePath = "~/bin/dependencies/InstantClient/";
    
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    strSourcePath += "Linux" + iBitNess.ToString();
                }
                else
                {
                    strSourcePath += "Win" + iBitNess.ToString();
                }
    
                strSourcePath = Server.MapPath(strSourcePath);
    
                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, true);
    
                    //if(strTargetFile.EndsWith("orannzsbb11.dll", StringComparison.OrdinalIgnoreCase))
                    if (System.Text.RegularExpressions.Regex.IsMatch(strTargetFile, @"^(.*" + RegexDirSeparator + @")?orannzsbb11\.(dll|so|dylib)$", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                        continue; // Unneeded exception thrower
    
                    try
                    {
                        LoadSharedObject(strTargetFile);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
    
                } // Next strSourceFile
    
            } // End Sub EnsureOracleDllsLoaded
    
    
            public static void RegisterGlobalFilters(GlobalFilterCollection filters)
            {
                filters.Add(new HandleErrorAttribute());
            } // End Sub RegisterGlobalFilters
    
    
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    "Default", // Routenname
                    "{controller}/{action}/{id}", // URL mit Parametern
                    //new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameterstandardwerte
                    new { controller = "Home", action = "Test", id = UrlParameter.Optional } // Parameterstandardwerte
                );
    
            } // End Sub RegisterRoutes
    
    
            protected void Application_Start()
            {
                EnsureOracleDllsLoaded();
                AreaRegistration.RegisterAllAreas();
    
                RegisterGlobalFilters(GlobalFilters.Filters);
                RegisterRoutes(RouteTable.Routes);
            } // End Sub Application_Start
    
    
        } // End Class MvcApplication : System.Web.HttpApplication
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why should I use templating system in PHP? The reasoning behind my question is:
Question: I need to read a CSV file. I use the FileHelpers library to
When working with namespaces such as System.Data.Odbc or System.Data.OracleClient the various data reader methods
Hi Just a fast question. I am trying to use System.ComponentModel.DataAnnotations in .NET to
For encryption/decryption of data which is written in txt files I try to use
i have a .net dll written in c# which reads data off a data
When modifying data in a SQL Server database you can use either System.DBNull.Value or
Just found this out, so i am answering my own question :) Use a
QUESTION: Re use of .NET Backgroundworker, is there not a way to let exceptions
I have a question regarding use of FFT. Using function getBand(int i) with Minim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.