This is about a Windows Forms application, .Net 4.0, Visual Studio 2010.
My imaging application uses PortableDeviceApiLib and PortableDeviceTypesLib using generated Interop libraries. This causes type information load failure when PortableDevice types are referenced UNLESS I build specifically for x86. However, in x86 my DLLImports from Shell32.dll cause a run-time "stack imbalance" error when the program terminates; this imbalance does not occur with other build, such as AnyCPU.
Another Windows Forms app on the same machine app exhibits no significant problems with the PortableDeviceApiLib, but it does not use Shell32.dll.
Bulding my imaging app with other than x86 causes a VS warning about 'MIDL' versus 'x86' incompatibilities potentially causing run-time failures.
Another wrinkle is that I'm using the recommendation in Enumerating Windows Portable Devices in C# to decompile, edit and recompile the Interop.PortableDeviceApiLib.dll to allow enumerating more than one portable device. This does not seem to affect the type library load failures.
I have usually used AnyCPU for .Net apps, both Forms and WPF. Any other ideas about build settings I could try?