fix 7z code to survive relocated dll
This commit is contained in:
parent
19d3a097b9
commit
c7b780def2
|
@ -131,12 +131,16 @@ namespace SevenZip
|
||||||
#if !WINCE && !MONO
|
#if !WINCE && !MONO
|
||||||
if (_modulePtr == IntPtr.Zero)
|
if (_modulePtr == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (!File.Exists(_libraryFileName))
|
//zero 29-oct-2012 - this check isnt useful since LoadLibrary can pretty much check for the same thing. and it wrecks our dll relocation scheme
|
||||||
{
|
//if (!File.Exists(_libraryFileName))
|
||||||
throw new SevenZipLibraryException("DLL file does not exist.");
|
//{
|
||||||
}
|
// throw new SevenZipLibraryException("DLL file does not exist.");
|
||||||
|
//}
|
||||||
if ((_modulePtr = NativeMethods.LoadLibrary(_libraryFileName)) == IntPtr.Zero)
|
if ((_modulePtr = NativeMethods.LoadLibrary(_libraryFileName)) == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
|
//try a different directory
|
||||||
|
string alternateFilename = Path.Combine(Path.Combine(Path.GetDirectoryName(_libraryFileName),"dll"),"7z.dll");
|
||||||
|
if ((_modulePtr = NativeMethods.LoadLibrary(alternateFilename)) == IntPtr.Zero)
|
||||||
throw new SevenZipLibraryException("failed to load library.");
|
throw new SevenZipLibraryException("failed to load library.");
|
||||||
}
|
}
|
||||||
if (NativeMethods.GetProcAddress(_modulePtr, "GetHandlerProperty") == IntPtr.Zero)
|
if (NativeMethods.GetProcAddress(_modulePtr, "GetHandlerProperty") == IntPtr.Zero)
|
||||||
|
|
Loading…
Reference in New Issue