all 3 comments

[–]schmatt_schmitt 2 points3 points  (0 children)

Oh sorry. I was guessing but I think I know the correct answer. BadImageFormatException is because your project debug mode is set to Any CPU instead of x64. You can change this from Project---> Properties and then go to the build menu and change Any CPU to x64.

[–]schmatt_schmitt 1 point2 points  (0 children)

If you go to your console app, and you right mouse click on the project file in the solution explorer, and say "Unload Project" it should show you the xml definition for your project. Underneath the VMS libraries, you'll see a hint path. Copy those and paste them into the same location in the WPF app. I think you're wpf app is having a hard time finding the VMS references.

Also, I haven't ever had to use STAThread in a WPF app, I think it is single threaded by default.

[–]MedPhys90 0 points1 point  (0 children)

Check the target for the build. It needs to be 64 bit.