La instalación del servicio de Windows falla
-
22-10-2019 - |
Pregunta
Estoy intentando instalar un servicio .NET 4 Windows en un servidor de producción: ejecutar instalación de installutil.exe me da este mensaje de error:
Se produjo una excepción al inicializar la instalación: System.BadImageFormateException: no se pudo cargar archivo o ensamblaje 'archivo: /// d: myservice.exe' o una de sus dependencias. Este ensamblaje está construido por un tiempo de ejecución más nuevo que el tiempo de ejecución cargado actualmente y no se puede cargar.
Obviamente, se queja de que el servicio se escribe en .NET 4. Pero el marco se instala correctamente en el servidor, ya que tengo otras aplicaciones .NET 4 en ejecución. Esta es la primera vez que intento instalar un Servicio.
Hice un poco de Google e intenté establecer la "CPU objetivo" en "AnyCPU" en configuraciones avanzadas del compilador. ¿Qué más me estoy perdiendo?
Solución
Most likely, you have a bitness mismatch. If this is a 64-bit server, then there's probably a 32-bit DLL somewhere that has the same name as the 64-bit DLL the program is trying to load. Or, on a 32-bit server, there's a 64-bit DLL somewhere.
I've found that when this happens, the application error log (Windows command eventvwr
) will tell me where the offending DLL is).