I am getting the following error when trying to create a new InfoPath form from a forms library:
The custom code in the form cannot be run. This functionality may be deactivated on the server. For more information, contact the server farm administrator.
The form codebehind doesn't do anything fancy - it just handles a couple of _Changed events by doing some date/time calculations and setting a couple of values on the form. Nevertheless, I inserted a [assembly:AllowPartiallyTrustedCallers] statement above the namespace declaration.
I used some techniques from Get user information without writing code to retrieve the username, title, department, and manager name of the person filling out the form (this is accomplished within the form, not in the codebehind). I also connected to a SharePoint list to retrieve some information which is then populated to the form.
I deployed the form as an administrator-approved form template. Then, I uploaded and activated it in Central Administration > Manage Form Templates.
Sandboxed solutions are enabled on the server. Form works fine when run locally.
What is causing the error?
Edit: I created another form and had no errors, until I added an empty codebehind for that form. Then I got the same error as above, even though there is no actual code in the codebehind. Am I missing a simple server setting somewhere?