SPSite: The Web application could not be found
You’re trying to use the SharePoint 2010 server side API’s but you’re getting the exception:
The Web application at https://... 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.
Then the root cause is probably not:
-Misconfigured AAM
-Missing App. Pool permissions
It is probably that you’re compiling for x86 platform target.
Change that to x64 and your code will probably work:
-thomas