Click here to Skip to main content
15,847,653 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried to run a .bat file, but got such an error as shown below:
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\XXX\OneDrive - XXX\Projects\MyWinService\WinServiceProject\bin\Debug\WinServiceProject.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format..

How to resolve the format problem? Thanks.

What I have tried:

Unable to run the install.bat file.
Posted
Updated 8-Sep-23 5:33am
v2
Comments
Dave Kreskowiak 7-Sep-23 19:02pm    
The error has nothing at all to do with running the batch file. What's going on is the batch file is trying to launch an app that cannot run on the machine because of what Richard described.

1 solution

The error message is clear, you are trying to run WinServiceProject.exe, but it is (possibly) not in a correct format. Most likely it is a 64 bit executable trying to run on a 32 bit machine. Or a 32 or 64 bit executable trying to access a library that has the opposite "bit-ness".
 
Share this answer
 
Comments
s yu 7-Sep-23 13:18pm    
Wonderful. Re-compiled w/ setting on "All Platforms" & "Any CPU". The bat file can be implemented. Thanks.
Richard MacCutchan 7-Sep-23 13:50pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900