I am trying to use https://code.google.com/p/twaindotnet/ for our internal app that is running on Windows 2008 terminal server (64 bit). I have found few remarks on the fact that this library cannot be used natively on 64 bit machine and that it (and all apps using it) should be compiled targeting x86 platform. (I am using VS2010) Problem is, however, that:
- sample application - TestAppWpf (from the TwainDotNET package) - works on (our) server normally when compiled targeting Any CPU (thus is running in 64 bit mode on the server).
- my (even the simplest sample) application that uses Prism with Unity/MEF always crashes with exception that "an attempt was made to load a program with an incorrect format (Exception from HRESULT: 0x8007000B)"
[used code is always the same:
Loaded += delegate
{
try
{
Twain _twain;
var hook = new WpfWindowMessageHook(App.Current.MainWindow);
_twain = new Twain(hook);
}
catch (Exception ex)
{
MessageBox.Show(GetText(ex, true), "twain", MessageBoxButton.OK, MessageBoxImage.Error);
};
};
catch part is just stupid "dump" at the moment... and the exception occurs at the first place when a call to twain_32.dll (DsmParent function) library is about to be made
[DllImport("twain_32.dll", EntryPoint = "#1")]
public static extern TwainResult DsmParent([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr windowHandle);
]
- I have also tried to recompile whole project and library to target x86 but there is still similar result - TestAppWpf works & my app does not.
- No need to mention that on my dev machine (32 bit) everything works as a charm.
I am completely lost trying to find the difference(s) between the sample app and my own application (both running in 64 bit environment).
Any suggestion/tip/or trick would be really appreciated.
Martin F.