Tuesday, April 26, 2011

Reference to class 'xxx' is not allowed when its assembly is linked using No-PIA mode

To fix this error you need to Change the Embed Interop Type to false in the properties of the reference.

Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format. in VB.NET 2010

Could not load file or assembly 'Interop.PortableDeviceApiLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. ?

Today, I wanted to add PortableDeviceApiLib assembly to my project to pull some information from a iPhone device. After I add reference to the dll. I started getting this issue. To fix this you need to change the Platform to x86

Project Properties> Build > Target Platform to "x86"

strange solution, but it works.