"Could not load file or assembly" error when you compile an SDK application for Microsoft Dynamics SL 2011

This article provides a solution to an error that occurs when you compile a Software Development Kit (SDK) application for Microsoft Dynamics SL 2011.

Applies to:   Microsoft Dynamics SL 2011, Microsoft Dynamics SL 2011 Service Pack 1
Original KB number:   2685054

Symptoms

When you compile a Microsoft Dynamics SL SDK application on a 64-bit workstation in Microsoft Visual Studio 2010, you receive the following error:

Could not load file or assembly 'file:///C:/Windows/assembly/GAC_32/Interop.SAF/8.0.0.0__31bf3856ad364e35/Interop.SAF.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Cause

There's an issue in Microsoft Visual Studio 2010 on a 64-bit workstations where it incorrectly assumes various DLL files (such as Interop.SAF) are 64 bit when they are in fact 32 bit.

Resolution

There are several options to work around this issue:

  1. Use a 32-bit workstation to compile the Microsoft Dynamics SL Software Development Kit (SDK) application.
  2. Use Microsoft Visual Studio 2008 instead.