this question has answer here:
i creating class library, hope put on nuget eventually. right now, targeting anycpu.
i want pinvoke dll, comes in both 32 , 64 bit versions. initially, thought i'd use 32 bit version, threw badimageformatexception. changed library target x86 only, , while works, requires caller 32 bit process too. naturally wouldn't work nuget project.
appreciate thoughts on how work 32/64 bit versions of native library, , how package in nuget (prefer not have 2 different assemblies).
you can check platform @ runtime , pinvoke different dlls.
static void nativefuncwrapper(){ if(environment.is64bitprocess){ nativefuncwrapper64(); //this calls 64-bit dll }else{ nativefuncwrapper32(); //this calls 32-bit dll } }
if want work without environment.is64bitprocess
, read how know process 32-bit or 64-bit programmatically alternative methods.
Comments
Post a Comment