How can I force an ANYCPU .net app to run as 32 or 64 bit?
-
03-06-2021 - |
سؤال
I have an Office Addin. It launches an app with runas=admin when it needs to set the license key in HKLM. up to Office 2007 Office is 32-bit. However Office 2010 comes in both a 32-bit or 64-bit version. That version determines if an HKLM key is in WoW or note.
Therefore I need to launch the application in the bitness that matches Office (and my AddIn). How can I do that?
Or in the alternative, how can I access both the WoW registry when running in 64-bit mode and the 64-bit (regular) registry when running in WoW?
I am on .NET 3.5.
thanks - dave
المحلول
You need to have two different exe's compiled respectively. You can't force the bitness of the exe beforehand.
نصائح أخرى
You can modify the .exe with CorFlags:
CorFlags.exe MyAssembly.exe /32Bit+
Will force 32bit, and:
CorFlags.exe MyAssembly.exe /32Bit-
Will turn it off again. There are some alternatives in this blog post.