View previous topic :: View next topic |
Author |
Message |
hs2
Joined: 27 Jan 2014 Posts: 3
|
Posted: Mon Jan 27, 2014 7:55 pm Post subject: Application does not find assemblies |
|
|
Hi!
I use the encryptor for encrypting my application. My bootstrapper is compiled in any cpu mode (the encrypted assembly too).
In the application directory there is only the exefile and the exefile.config. The directory also includes two folders (x86 and x64 with the propper dll files).
The config-File looks like this:
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="x86;x64"/>
</assemblyBinding>
</runtime>
</configuration>
On x86 systems everything is running fine. But on x64 systems the application does not find any dll located in the x64 folder (HRESULT: 0x8007007E). When I insert the exefile into the x64 folder and start the application from this location, everything runs fine.
It searches the dll files only in the application directory (I used process monitor to figure this out).
Can you please tell me what I'm doing wrong?
Thanks you in advance! |
|
Back to top |
|
|
hs2
Joined: 27 Jan 2014 Posts: 3
|
Posted: Mon Jan 27, 2014 9:37 pm Post subject: |
|
|
Found a solution:
Code: |
[DllImport("kernel32.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern bool SetDllDirectory(string pathName);
// Manually set the DLL load path depending on the process.
var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
if (Environment.Is64BitProcess)
{
path = Path.Combine(path, "x64");
}
else
{
// X32
path = Path.Combine(path, "x86");
}
SetDllDirectory(path);
|
|
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jan 28, 2014 10:26 pm Post subject: |
|
|
Great thanks for posting the solution. _________________ Infralution Support |
|
Back to top |
|
|
|