Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda