When you develop with SharePoint, sometimes you have some confusing errors. Here is one of them…
The complete error message is
The Web application at http://<servername>/<sitename> could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
It is not complex to succeed having this code working. Just look at the following screenshot:
Now it is running. So, what’s the difference?
Have a look to the toolbar and you will see the only difference…
Yes, this message is not clear but the main cause is that you are developing a application targeting x86 (32 bits) environment and running it on a 64 bits environment… Be careful about this. Do not forget to use development, test and production environments with similar configurations.