A few days ago, Mike Morton (MS) and the Visual Studio team released the Visual Studio 2010 Sharepoint Power Tools that allow us to create Visual Web Part running in sandBox mode but also to display build errors when we use unauthorized sandbox code ; you can download the tool here.
Create a Sharepoint 2010 sandbox empty project, add a Sharepoint project Item and the new template will show up:
Select Visual Web Part (sandBoxed) and a web part will be generate with an ascx control :
However, the ascx control won’t be deployed:
But everything relies on pure .Net code :
The other nice feature is that you won’t be able to type unauthorized code (class & methods) like SPSecurity, SPFram..: