views:

939

answers:

3

Hi Everyone,

I have a native C code, I compiled the code in vc++ 2008 and its compiled with 'x64' as platform in configuration manager and I have an c# application which is also compiled with 'x64' as platform and it calls the dll function. I have used Dllimport to call the function from the dll like below.

using System.Runtime.InteropServices;

namespace test
{
public partial class Form1 : Form
{

  [DllImport("mtest", CharSet = CharSet.Ansi)]
    public extern static void e_path(string path);

    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        MessageBox.Show("test");
        swe_set_ephe_path("E:\\Gan");
    }
}

}

at the time of running the application I am getting the error as below:

An unhandled exception of type 'System.DllNotFoundException' occurred in test.exe

Additional information: Unable to load DLL 'mydll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Could any you please help me out to resolve this. If I run both the dll and the applicaition its working fine. But I need the dll functions to be called from my ASP pages so I need both the dll and application as 64 bit.

ADDITIONAL INFORMATION : when I checked the dll for dependency using dependency walker for 64-bit It shows that the Kernel32.dll and NTDLL.DLL and mydll.dll is x64.

please help me out with this.

Thanks in Advance,

A: 

The problem is that your dll depends on some other dll and that other dll can't be located because it is on some path where the loader doesn't search for it or that dll is not 64-bit.

sharptooth
when I checked the dll for dependency using dependency walker 64-bit It shows that the Kernel32.dll and NTDLL.DLL and mydll.dll is x64.
Ganesh Astroved
A: 

Hi Everyone,

Thank for your help.

When I placed the dll under C:\Windows\System32\ the error resolved.

Please let me know the reason for that. Why it doesnt work under "C:\Windows\syswow64"

So do when do we need to place the dll in SYSWOW64 and when we need to put in System32.

Thanks in Advance

Thanks,

Ga

Ganesh Astroved
That's because System32 is the system folder of the 64 bit OS, while SysWOW64 is the system folder of the 32 bit OS. Very confusing, I know... Basically, with 64 bit executables on 64 bit OS you should just work as you're used to, namely use system32. The 32 bit intermediatte layer acts as "Windows over Windows 64", hence the WOW64.
eran
+1  A: 

Hi Ganesh, on x64 platforms the SYSWOW64 directory contains files for 32bit applications. You will find the same differentiation in the registry, where SYSWOW64 contains entries for x32 applications. Greetings

Comment: The registry key containing 32bit entries is Wow6432Node and resides in //HKEY_LOCAL_MACHINE

usac