module was built either with optimizations enabled or without debug information

The following module was built either with optimizations enabled or without debug information

When you get the above error you can resolve it by the following way, Tools –> Options –> Debugging –> General –> Enable Just my code (Managed only) –> un check "Warn if no user code on launch" 

I encountered this problem in Visual Studio 2008 and like others here, my project settings did not have optimizations enabled and debugging information was configured. My problem turned out to be that the project assemblies stored in the GAC were from an older build. I think when I started debugging, VS tried to map between the GAC assemblies and the new source and could not do so and threw up this message. Deleting my old assemblies from the GAC resolved my issue.