It’s a follow-up from this.
Windows Phone 8 C# project (MyApp), migrated from WP7.1. I’ve added a native Windows Runtime component library (AppLib) to the solution, created a reference. There’s a public sealed ref class (MyClass) in it. There’s a reference to it in the C# code (in OnLoaded of the main XAML page). The whole thing builds – meaning the metadata of the component is being generated.
When I’m trying to run on the emulator, the project fails with the exception or type BadImageFormatException with the following message:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
The error typically pops up when you try to mix CPU types in .NET.
The active platform is “Mixed platforms”. In the Configuration Manager, it’s configured to build MyApp for “x86” and AppLib for “Win32”. In a vanilla freshly generated project that runs fine, the config is identical.
Question – what’s wrong with that configuration? What do I need to check?
EDIT: I’ve added a second, blank C++ library to the solution – TestLib. This one loads and works as expected.
EDIT2: excluded everything from build in AppLib – it works. Now I’ll be adding lines one by one, see which one causes the issue…
Totally my fault. When I changed the namespace of AppLib (see the linked question), I’ve left one little declaration in the library in a
MyAppnamespace.The error is still misleading. I’d delete the question, but since the error message is sure to send someone on a wild goose chase with build CPU type and whatnot, let it remain.