0

In my application (vs 2012) I'm using

Microsoft RDP Client Control

(COM) to connect remotely to a machine. It's working all well unless I run my exe on a 32bit OS, then BadImageFormatException is thrown!

Error log:

Could not load file or assembly Interop.MSTSCLib or one of its dependencies. The system cannot find the files specified.

1- I tried different versions of the COM (Microsoft RDP Client Control version 2 through 10), plus "Microsoft Terminal Services Client Control"

2- I tried to set the target platform to Any CPU, x86, x64

3- I tried to embed the library

I have to make sure this app works on both 64 and 32 bit OS, Any Ideas??

Saleem
  • 709
  • 2
  • 13
  • 34
  • Don't just copy the EXE file, you have to copy the Interop file as well. The exception message you quoted does not match the exception type, that's just a file-not-found message. The machine must have the correct .NET Framework version installed, whatever you used. – Hans Passant Mar 20 '14 at 13:09
  • But I added the used library to the System32 folder, before ading them it wouldn't work on any OS, bu after I added them it only worked on 64bit OS. – Saleem Mar 20 '14 at 14:48
  • Never ever copy files to system32, the CLR never looks there anyway. – Hans Passant Mar 20 '14 at 15:11
  • What should I have done then if I didn't found the DLL there?? – Saleem Mar 20 '14 at 15:16
  • Copy *all* the files from your bin\Release directory to the install directory on the target machine. – Hans Passant Mar 20 '14 at 15:25
  • It did help!! :D I only built my app with target platform x86 and copied the DLLs within the same path of my exe Thank you :D Please add this as a solution to accept it. – Saleem Mar 21 '14 at 14:26

1 Answers1

0

I found the solution here, in the second answer: here

But all I did is built my app with target CPU x86 and copied DLLs within same path of my exe, and all worked well

Saleem
  • 709
  • 2
  • 13
  • 34