Using BusinessConnectorNet dll into a WCF webservice

The post may be a little outdated, but I spent several hours today just to recall something I forgot from quite some time ago. (note, this post is referring to the BusinessConnectorNet dll 2009 version, which is built on 32-bit architecture).

Not sure if this applies to the 2012 BCNet, I think not, but since I haven't tested it I do not know for sure (however, the use of BCNet in 2012 is not recommended anymore, due to several reasons I won't go into this post; still, for people using 2009 this is something that has to be done).

The error you get is: "Could not load file or assembly 'Microsoft.Dynamics.BusinessConnectorNet' or one of its dependencies. An attempt was made to load a program with an incorrect format.".

The fix is quite simple: go to the application pool for the Web Site hosting your WCF service, open the Advanced Settings ..., and set to True the Enable 32-bit Applications.