0

So I wrote service that is constantly checking some folder and if there are files, they are uploaded to Oracle Database.

Everything is working fine when I'm running it in Visual Studio in debug mode. But when I'm doing release and installing actual service and run it, it throws oracle exception when trying to connect:

Could not load file or assembly 'Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Service is running and working and writing this exception to log file, so this is not direct service problem. I'm installing this service on same machine where I run debugging so Oracle client is installed and working fine. I also tried to install in on another machine but it trows same exception.

My guess is that there is some problems with rights and how service runs but since it's my first windows service I have no idea where exactly problem is and what to look for. It's installing as local service, when debugging it's running as my user (if I'm correct).

HoTTab1CH
  • 199
  • 3
  • 20
  • 1
    `An attempt was made to load a program with an incorrect format.` tells that you are trying to use *32* bit program with *64* bit or vice versa. – TheVillageIdiot Mar 27 '18 at 08:05
  • I tried to compile as 32/64/any mode non of them worked, but if it's 32/62 bit problem, why it's working fine when I'm debugging? Or where else can be my problem with version? – HoTTab1CH Mar 27 '18 at 08:25
  • 1
    Most likely you compiled to 64-bit but debugging is typically done in 32-bit (at least in older Visual Studio debugging is not possible in 64-bit mode). In case you like to use both, 32-bit and 64-bit follow this instruction: https://stackoverflow.com/questions/24104210/badimageformatexception-this-will-occur-when-running-in-64-bit-mode-with-the-32#24120100 – Wernfried Domscheit Mar 27 '18 at 08:46
  • Download the [Sysinternals Process Monitor](https://learn.microsoft.com/en-us/sysinternals/downloads/procmon) There you can monitor which files are attempt to be loaded. – Wernfried Domscheit Mar 27 '18 at 08:53
  • Thanks everybody. It was indeed 62/32 version problem. It was 64 bit oracle client installed and debugging was in 64 bit mode but I didn't notice that this setting is completely separate for debugging and release, now changed release to strictly x64 and it's working. – HoTTab1CH Mar 27 '18 at 09:07

1 Answers1

0

Thanks everybody. It was indeed 62/32 version problem. It was 64 bit oracle client installed and debugging was in 64 bit mode but I didn't notice that this setting is completely separate for debugging and release, now changed release to strictly x64 and it's working.

HoTTab1CH
  • 199
  • 3
  • 20