Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
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??
Posted

Is the Microsoft RDP Client Control a native DLL?

If your .NET application is built for 64-bit, you'll also need to include a 64-bit native library. Likewise, the same goes for a 32-bit application. While your .NET program might be AnyCPU, or even 32-bit, and the native library isn't the right architecture of the current platform it's running on, you'll get a BadImageFormatException[^].

As far as I can see you have two/three options here, and for all options you'll need the 32-bit version of the Microsoft RDP Client Control library.
1) You compile your .NET program as x86. It'll be a 32-bit program (which runs perfectly on a 64-bit OS) and it'll load the 32-bit library.
2) You create two different versions of your .NET program. One 64-bit, and the other 32-bit. And with each version you redistribute the appropriate library.
2a) You can go down the road of making an AnyCPU application, however, you'd need to dynamically load the appropriate library then. Here's an example[^] of that.

Option 1 is probably the easiest to do, unless you find it really important to have a 64-bit version of your application on a 64-bit OS.
 
Share this answer
 
v2
Comments
saleem_deek 20-Mar-14 11:13am    
Thx for your reply.
I built my app as x86, and it did run perfectly on 64bit OS, but not on 32bit OS, so I don't really know what to do.
Maarten Kools 20-Mar-14 11:52am    
Perhaps this[^] can help you? (scroll down to the second answer).
I found the solution here, in the second answer:
http://social.msdn.microsoft.com/Forums/en-US/5a92a204-81fe-4c6f-bfc3-ef04dc932ed0/could-not-load-file-or-assembly-interopactiveds-version1000-cultureneutral?forum=netfx64bit[^]

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 :D
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900