Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Restart .NET AnyCPU exe with different bitness

I have a .NET exe compiled for "AnyCPU", so it can theoretically run in both 32-bit and 64-bit mode (on a 64-bit operating system). Since my exe strongly interacts with MS Office, I need to run it with the same bitness as the installed Office version. (Please take this requirement as granted, I will gladly provide details in the comments, if you are interested.)

Now, I have thought up a solution for this, but it seems more complicated than necessary:

  1. Compile two versions: MyExe32.exe and MyExe64.exe, targeting x86 and x64, respectively, instead of AnyCPU.
  2. Create a launcher application Launcher.exe, which determines the bitness of the locally installed Office version (I know how to do that) and then starts MyExe32.exe or MyExe64.exe.

This would work, but I'd rather have a single, simple MyExe.exe with something like the following pseudo-code during start-up:

if (Environment.Is64BitProcess && IsOffice32BitInstalled)
{
    // restart myself in a 32-bit process instead of a 64-bit process
    ???  // <-- this is where I need help
}

Is that possible? If yes, how?


Notes: I know about the CorFlags utility, but I'd rather have a solution that does not require modifying the exe itself at runtime.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Is restarting via runtime parameter an option?

dotnet run -r win-x86

https://stackoverflow.com/a/63252884/18152293

over 4 years ago · Santiago Trujillo Report

0

Apparently I don't have reputation enough to post comments, so posting this as an answer instead.

If, as you say, you're deploying to an internal network, I'd recommend using a launcher anwyay.

That way users can have a single network shortcut to the launcher, that doesn't move around. The launcher can determine which bitness is required, and which is the latest release, and launch the EXE for that release.

If you allow users to go directly at the EXE, you will either encounter problems with users having the EXE opened, so you can't overwrite it, or have to create new user shortcuts for every release.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!