c# - Loading a 32-bit dll in a 64-bit process -
this question has reply here:
target 32 bit or 64 bit native dll depending on environment 3 answers dllimport - effort made load programme wrong format [duplicate] 1 replyi want c# application conditionally run native method, conditionally choosing run either x86 or x64 version of dll. whenever seek load 32 bit dll below error:
unhandled exception: system.badimageformatexception: effort made load programme wrong format. (exception hresult: 0x8007000b) @ <exename>.minidumpmethods.minidumpwritedumpx86(intptr hprocess, uint32 processid, safehandle hfile, minidump_type dumptype, intptr expparam, intptr userstreamparam, intptr callbackparam) background context: want binary take memory dump of given process. based on whether or not process it's taking memory dump of 32 or 64 bit it'll take run minidumpwritedump method x86 or x64 version of dbghelp.dll.
i'm doing following:
[suppressunmanagedcodesecurity] internal static class minidumpmethods { [dllimport("dbghelp.dll", entrypoint = "minidumpwritedump", callingconvention = callingconvention.stdcall, charset = charset.unicode, exactspelling = true, setlasterror = true)] [return: marshalas(unmanagedtype.bool)] public static extern bool minidumpwritedump( intptr hprocess, uint processid, safehandle hfile, minidump_type dumptype, intptr expparam, intptr userstreamparam, intptr callbackparam); [dllimport("dbghelpx86.dll", entrypoint = "minidumpwritedump", callingconvention = callingconvention.stdcall, charset = charset.unicode, exactspelling = true, setlasterror = true)] [return: marshalas(unmanagedtype.bool)] public static extern bool minidumpwritedumpx86( intptr hprocess, uint processid, safehandle hfile, minidump_type dumptype, intptr expparam, intptr userstreamparam, intptr callbackparam); } any thought how can conditionally load either x86 or x64 version of dll?
(note: dbghelpx86.dll x86 version of dbghelp.dll renamed)
thanks
you cannot load 32 bit dll 64 bit process. back upwards have have 2 different exe's, 1 compiled 64 bit , 1 compiled 32 bit.
if run 64 bit process , encounter 32 bit dump, you'll have launch 32 bit version of exe process dump file. 1 time processed can utilize sort of ipc (interprocess communication) mechanism send results 64 bit process.
c# windows dll .net-4.5 32bit-64bit
No comments:
Post a Comment