After several hours Google'ing, I have no the solution to this problem.
I have developed a DLL in unmanaged C++. I have placed that DLL in SysWOW64 folder since this is a 64 bit computer.
On the other hand, I have a Winforms application developed in C# that imports the functions contained in the DLL. I use DllImport("name.dll"), however a System.DllNotFoundException is thrown.
The whole solution is configured for x64 platform.
If I place the DLL in the executable directory, it works.
I want the DLL to be in the system folder because of simplicity in development. I am developing this project in 2 different computers (a desktop PC and my notebook). The PC has 32 bits platform, while the notebook is 64 bits, with different folders.
To syncronize projects in both computers I use subversion repository. I can, obviously write a Post Build event to copy the DLL from the C++ project folder to the output folder of the main executable, but I will need to change the Post build command every time I move from notebook to PC or vice versa.
Any idea why the DLL is not found in the System folder? and most importantly, is there a way to solve it?
Thanks Jaime
The
SysWOW64is actually the 32 bit system directory. For a 32 bit program, the file system redirector will redirectsystem32toSysWOW64.SysWOW64.system32.This would explain the problem you face.
For what it is worth, you really should not be modifying the system directory. It belongs to the system and applications should not modify it.