Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

dll for 32bit and 64bit

hello there,
I have a source code for a 32bit and 64bit dll file on VS2010..
I would like to know how to make the app load the correct dll file on run time..
so if its a windows 32bit load the 32bit dll or if its 664bit then load the correct dll file..
how can I do this?
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HooKooDooKu
HooKooDooKu

VS2010 gives you all sorts of build options.  Why not simply name the resulting application and DLL differently for 32 and 64 bit versions of the project:
My.exe + My.dll
My64.exe + My64.dll.
Have the 32 bit version link to My.lib import library and the 64 bit version link to My64.lib import library.
Avatar of XK8ER

ASKER

somehow I have a project that works a bi different..
when I go to VS2010 > properties > references > I see component Name.
when I compile the exe file and run it.. it knows which dll file to load 32 or 64 dll..
both dll files are located in C:\Windows\System32
hows that possible?
May be its a loader component that you are referencing and it loads and uses a different DLL based on 32 vs 64 bit using the technique suggested by kaufmed.
Avatar of XK8ER

ASKER

when I look at the path from
VS2010 > properties > references > componentName.

Interop.componentName.dll
>>I have a source code for a 32bit and 64bit dll file on VS2010..

OK - BUT that may well be different technology to the other dll you talk about.
A .net program/library does NOT compile to a specific executable code, it compiles to an intermediate which should be 32/64 bit independant.  When the app/dll then runs the .net environment compiles it to either the 32 bit or the 64 bit version as required.  So one .net dll will cover both 32 and 64 bit operating systems.
When the app/dll then runs the .net environment compiles it to either the 32 bit or the 64 bit version as required.  So one .net dll will cover both 32 and 64 bit operating systems.
Not to say I'm not doing something wrong, but I have run into issues where using a 3rd-party library that was compiled for a specific environment (ODP.NET) did force me to pick whether or not I was targeting a 32- or 64-bit environment in order to properly load the 3rd-party library.
Hmmm - maybe instead of will I ought to have said should.
system32 should not contain 64-bit dlls. if it does nevertheless the dll either was never used, or the 64-bit program that loads it, explicitly uses the path to system32 folder, or the 64-bit dll isn't 64-bit but 32-bit (only the name contains 64 ???).

Sara