I have trouble working with an unmanaged Assembly from my WPF Application. Here's my setup, boiled down to a simple sketch:
X64 RUNTIME____________________
| |
| AS_EXEC (executing Assy, x86)|
| | |
| | |
| AS_INT (interfaces, AnyCpu)|
| | |
| | |
| AS_WRA_1 (wrapper, x86) |
| | | |
| | AS_UNM_1 (unmanaged, x86)|
| | |
| AS_WRA_2 (wrapper, x64) |
| | | |
| | AS_UNM_2 (unmanaged, x64)|
| | |
| AS_WRA_3 (wrapper, x86) |
| | |
| AS_UNM_3 (unmanaged, x86)|
|______________________________|
What I want to do is test AS_WRA_1
.
Since
AS_WRA_1
references unmanaged code that will work inX86
only, I consider it best to set this project toX86
itself - just to prevent usage that will causeBadImageFormat
exceptions.AS_INT
contains interfaces for allAS_WRA
implementations and is set toANY CPU
.I'm in 64 Bit runtime, so I also set
AS_EXEC
toX86
.AS_WRA_2
works in 64 Bit only,AS_WRA_3
32 Bit (that means basically I cannot run them at the same time, but since I want to testAS_WRA_1
only, I more or less happily neglect that - welcome back, DLL hell!).
At runtime, I use reflection to create an instance from the wrapper the user selects in the UI. Strangely, the result is the following:
- I can create instances from
AS_WRA_2
- I get BadImageFormatExceptions for
AS_WRA_1
andAS_WRA_3
.
This is exactly the opposite of what I had expected...What am I doing wrong here?