简体   繁体   中英

SQL Server CE BadImageFormat

I have searched for weeks for a solution to this, and so far have found nothing yet. I am using a local database to store ZipCode & AreaCode info. This works fine, loads correctly, reads from DB and displays results on every computer except the development machine. I have deployed it to multiple other computers and everything works fine, but on the development machine it comes back with a BadImageFormat exception when I try to read from the database.

I have gone through the Add/Remove Programs screen on both my desktop (development machine) and my wife's laptop (where it works with no problem). Both lists of installed programs are identical as far as anything regarding SQL, SQL Server CE, ADO.Net, Visual Studio, etc is concerned. I have the dll files included in the .exe file, so they are using the same version.

At one point this did work on the development machine, and then I think I uninstalled something and it broke it. Since then I have installed a fresh copy of windows 7 and a fresh copy of VS (b/c of a hard drive upgrade, not because of this problem). Still it does not work. The database is in SQL Server CE 3.5 format.

I can pretty much guarantee it can't be a connection string issue, as that doesn't change betwen machines. I wouldn't even worry about it honestly, except that I need to add to/adjust the database, and I'm paranoid changing anything in it will break it on the other machines, which is unacceptable.

Can anybody think of anything I might be missing?

Update:

In one of those great moments of irony, after posting this question I had a sudden thought. The one difference I can put my finger on between the two is that on the Dev machine I just run it from VS, or from the Projects\\Bin folder. On the others I copy the exe and dll's to a folder from a CD. So thinking of this, I created a folder on the desktop of the Dev computer, copied in the same way I do to test on other machines, and everything worked fine. So I assume this is then a folder permissions issue or something similar. I tried changing the Bin folder to be not Read-only, but still from Debug it doesn't work.

Is there a known way to correct this?

The BadImageFormat exception refers to the fact that the SqlCE dll you are using is not the appropriate one for the architecture you are running on. Your local computer may have a version of SQL CE for 32bit (x86) whereas your dev machine may be a 64bit(x64) architecture. If you replace the SQL CE DLL for the appropriate architecture in your DEV machince your program should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM