Question

I'm working on an ATL project. When I build my solution under a x64 system it doesn't work on x86 architecture and vice versa. (I can't register the dll I generated in a different architecture). Where could be the problem? any help would be appreciated.

Was it helpful?

Solution

The symptoms you mention are unlikely to be exactly as described. It does not matter if you build in Win32 or x64, what does matter is what target platform is selected when you build. Then,

I can't register the dll I generated in a different architecture

In 32-bit Windows there is no way you can use x64 DLL, this is behavior by design. However, in 64-bit systems you typically have both 32 and 64-bit "environments" and you can use and register Win32 DLL there. If you cannot, the typical cause is that a mandatory dependency is missing (CRT or another DLL, Dependency Walker might be helpful). You need to check this out because the Q does not have relevant information on this.

Another possible problem might be related to "use" of the DLL, apart of its registration. If you "use" the DLL from your, for instance, .NET app build for AnyCPU platform, and the application runs as 64-bit process in 64-bit Windows, then it won't pick and use your 32-bit DLL.

OTHER TIPS

[D:\commands]
> type regsvr_32bit.bat
@echo off
rem "%SystemRoot%\Syswow64\regsvr32.exe" %s*
start "", regsvr_32bit.exe.lnk "%~f1"

[D:\commands]
> _

The ".lnk" file is an ordinary Windows shortcut.

Instead you can use the path shown in the comment.


Note that 64-bit executables are located in the [system32] directory, while 32-bit executables are located in the [SysWOW64] directory. While this can be pretty confusing for those who think, it's a compatibility measure that Just Works™ for those who don’t think. Since I’m prone to thinking I struggled for a long while with this…

Here’s the upshot for regsvr32 (as an example):

[C:\Program Files (x86)\Microsoft Visual Studio 11.0]
> dumpbin /headers "%SystemRoot%\Syswow64\regsvr32.exe" | find "machine"
             14C machine (x86)
                   32 bit word machine

[C:\Program Files (x86)\Microsoft Visual Studio 11.0]
> dumpbin /headers "%SystemRoot%\system32\regsvr32.exe" | find "machine"
            8664 machine (x64)

[C:\Program Files (x86)\Microsoft Visual Studio 11.0]
> _
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top