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_1references unmanaged code that will work inX86only, I consider it best to set this project toX86itself - just to prevent usage that will causeBadImageFormatexceptions.AS_INTcontains interfaces for allAS_WRAimplementations and is set toANY CPU.I'm in 64 Bit runtime, so I also set
AS_EXECtoX86.AS_WRA_2works in 64 Bit only,AS_WRA_332 Bit (that means basically I cannot run them at the same time, but since I want to testAS_WRA_1only, 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_1andAS_WRA_3.
This is exactly the opposite of what I had expected...What am I doing wrong here?