0

I have been developing a Windows application for the past 6 months for my internship. This program works as it should do on the laptop where its programmed, but I need to set the program on another laptop. I installed the same dotnet core version (3.0.100) and started the .exe with all the DLLs necessary in the same directory (as it is compiled). But when I do this I get the error shown below.

[ERROR][1/23/2020 7:58:41 PM][Thread 0006][akka://ModulairVisionFramework/user/InterfaceCameraActor] Error while creating actor instance of type CameraSystem.InterfaceCameraActor with 0 args: ()
Cause: [akka://ModulairVisionFramework/user/InterfaceCameraActor#1923472091]: Akka.Actor.ActorInitializationException: Exception during creation
 ---> System.TypeLoadException: Error while creating actor instance of type CameraSystem.InterfaceCameraActor with 0 args: ()
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.BadImageFormatException: Could not load file or assembly 'VimbaNET, Version=1.8.0.27270, Culture=neutral, PublicKeyToken=96b729f24f119b9a'. An attempt was made to load a program with an incorrect format.
File name: 'VimbaNET, Version=1.8.0.27270, Culture=neutral, PublicKeyToken=96b729f24f119b9a'
   at CameraSystem.InterfaceCameraActor..ctor()

   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
   at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Akka.Actor.Props.ActivatorProducer.Produce()
   at Akka.Actor.Props.NewActor()
   --- End of inner exception stack trace ---
   at Akka.Actor.Props.NewActor()
   at Akka.Actor.ActorCell.CreateNewActorInstance()
   at Akka.Actor.ActorCell.<>c__DisplayClass109_0.<NewActor>b__0()
   at Akka.Actor.ActorCell.UseThreadContext(Action action)
   at Akka.Actor.ActorCell.NewActor()
   at Akka.Actor.ActorCell.Create(Exception failure)
   --- End of inner exception stack trace ---
   at Akka.Actor.ActorCell.Create(Exception failure)
   at Akka.Actor.ActorCell.SysMsgInvokeAll(EarliestFirstSystemMessageList messages, Int32 currentState)

[INFO][1/23/2020 7:58:44 PM][Thread 0008][akka://ModulairVisionFramework/user/InterfaceCameraActor] Message Initialize from akka://ModulairVisionFramework/user/FrameworkActor to akka://ModulairVisionFramework/user/InterfaceCameraActor was not delivered. 1 dead letters encountered.

This error System.BadImageFormatException: Could not load file or assembly gives me the idea that I may use the wrong DLL of VimbaNET, but I'm 100% sure that I use the right one. If I do use the wrong DLL of VimbaNET then I do get the same error as above, but I also get the error if I use the right DLL. I also tried to compile the application on the new laptop with the same IDE, but the result is the same.

Both of the laptops are 64 bit.

Does anyone know how I can solve this issue?

The 32bit version of of my application gives the same error.

Settings that I use to compile and run the program in 64bit. enter image description here

Settings that I use to compile and run the program in 32bit. enter image description here

assembly Information of all 3 assemblies that are involved in the issue.

VimbaNET is the DLL that causes the issues

CameraSystem is my own Assembly that used VimbaNET

ModulairVisionFramework is the main application that makes use of the CameraSystem assembly enter image description here

wes
  • 379
  • 3
  • 15
  • is that a web application or windows application ? – Arunprasanth K V Jan 24 '20 at 08:14
  • Is your developer laptop installed with a 32-bit operating system? – Lasse V. Karlsen Jan 24 '20 at 08:15
  • @ArunprasanthKV A windows application – wes Jan 24 '20 at 08:19
  • @LasseV.Karlsen 64 bit, both laptops are 64 bit – wes Jan 24 '20 at 08:19
  • Then it should work or not on both machines, ie. they should behave the same way. The BadImageFormat exception is thrown when a 32-bit process tries to load a 64-bit assembly, or vice versa. Are you sure it is loading the same *file*? Could it be that you copied a 32-bit copy to the other machine, but used a 64-bit file on the developer laptop? – Lasse V. Karlsen Jan 24 '20 at 08:22
  • How are you running the program? Could it be that you've loaded it into a 32-bit process on the other machine, but debug it as a 64-bit process on the developer laptop? – Lasse V. Karlsen Jan 24 '20 at 08:23
  • Does this answer your question? ["An attempt was made to load a program with an incorrect format" even when the platforms are the same](https://stackoverflow.com/questions/2023766/an-attempt-was-made-to-load-a-program-with-an-incorrect-format-even-when-the-p) – Silvermind Jan 24 '20 at 08:31
  • @LasseV.Karlsen I have copied everything at once. The 32bit and the 64bit version of the program. Everything is in its own directory same as the development computer. – wes Jan 24 '20 at 08:54
  • @Silvermind I checked and all of the build check boxes are selected. – wes Jan 24 '20 at 08:57
  • @wes There is more in the answers then just checkboxes. Also one of the answers suggest you to uncheck the `prefer 32bit` checkbox. So that's the opposite of having everything checked. – Silvermind Jan 24 '20 at 09:05
  • @Silvermind my apologies, I mean the "Build" checkbox in the solution configuration. That one is set. I went through the other option, but wasn't able to find a solution. – wes Jan 24 '20 at 09:15
  • On your development machine, with your program loaded, type **tasklist /m**. This will tell you which DLLs it uses. On you target machine, when it crashes, type **tasklist /m** and check that the DLLs are the same. Alternatively, try running from windows\syswow64\cmd.exe. – cup Jan 24 '20 at 09:43
  • @cup Thank you, I checked and When the program is loaded on the dev laptop it uses some DLLs. on the other laptop I checked with tasklist after it crashed, it uses allot more DLLs – wes Jan 24 '20 at 10:34
  • @cup I ran the application from windows\syswow64\cmd.exe but I got the same error – wes Jan 24 '20 at 10:53

1 Answers1

0

Installing .NET 3.5 solves the problem since Vimba SDK has a dependency to .NET 2 (no, not .NET Standard or Core 2) (read the Vimba C# API documentation). .NET 3.5 includes .NET 2 runtime.

Batuhan
  • 100
  • 10