views:

113

answers:

1

Question: I use an embedded Firebird database in ASP.NET.

Now, Firebird has a .NET wrapper around native dlls.

The problem is, with the .NET compilation and execution process, the dlls get shadow copied to a temporary folder. Unfortunately, only the .NET dlls, and not the native dll.

See http://msdn.microsoft.com/en-us/library/ms366723.aspx for details.

Now, this makes it necessary to put the unmanaged dll somewhere into the system32 directory (or any other directory in the path environment variable).

Now, I want to change the wrapper/native dll (opensource), so it loads the dlls also if they are only in the bin folder.

Now, my problem is, how can I, in .NET, load an unmanaged dll from an absolute path ?
The absolute path is determined at runtime, not at compile-time...

+2  A: 

Embed the native dll in your assembly.

On Application_Start(), check Environment.CurrentDirectory or Assembly.GetExecutingAssembly().Location or whatever actually points to where you want to be, for the file and if not present, stream it out via Assembly.GetManifestResourceStream().

Note, that this will likely cause an appdomain recycle, e.g. restarting your app, but since you are just starting it up, it is a non-issue.

Not sure why you want an absolute path, epecially for an unmanaged dll. You will get better mileage with less pain if you simply locate the unmanaged dll in the same directory as the assembly that is calling it.

Sky Sanders
Any solution that doesn't require me putting the unmanaged dll into a path folder is welcome. Absolute path was my idea, but embedding would certainly be better.
Quandary