44

I've been given a windows service which references a COM component that only runs on 32-bit. My machine is x64, so the service tries to start, fails to create the COM component, and dies.

I don't have the source, just the .exe file. Is there any way to force a service to start in 32-bit mode on a win64 machine?

Steve Cooper
  • 20,542
  • 15
  • 71
  • 88

2 Answers2

73

Maybe the .NET tool corflags will help:

corflags /32bit+ myservice.exe

Thomas Freudenberg
  • 5,048
  • 1
  • 35
  • 44
  • +1 for the great answer, but the options come last: Usage: Corflags.exe Assembly [options] – BQ. Aug 03 '10 at 10:34
  • 1
    I had a problem where I got the message `corflags : error CF001 : Could not open file for writing` the solution was to add /force – David Knight Apr 25 '12 at 08:30
  • Same problems are for services built as .dll and debugged in VS through WcfSvcHost. In this case, you can switch the flag on the WcfSvcHost itself. [see article](http://coding.abel.nu/2012/04/debugging-a-wcf-service-using-a-32-bit-dll/) – quetzalcoatl Jul 09 '15 at 12:57
2

corflags.exe comes with the Windows SDK, not .NET.

corflags.exe needs to run only once against the target service exe. Then the service will run in 32-bit mode thereafter.

Note the argument needed is /32bitreq+ or /32bitpref+ .

corflags.exe /32bitreq+ myservice.exe

David B
  • 21
  • 1