Question

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?

Was it helpful?

Solution

After spending much of today on the phone with Microsoft developer support, it turns out that this is a legitimate bug. It was fixed by the August 2011 cumulative update for SharePoint Server. Once I installed that successfully, the above error no longer occurred.

OTHER TIPS

Make sure the form is set to Full Trust under the Security and Trust section of Form options.

InfoPath allows you to add a form as administrator approved without making sure it is set to Full trust, however code solutions require it to be set.

I was working with Browser-enabled forms about a year ago and was having similar problems to what you have described. Zork is right in that it needs to be Full Trust, but you also need to digitally sign the form for coded web forms. This is found in the Advanced Form Options > Security and Trust, under the heading Form Template Signature.

You can sign it as yourself but this won't work on other users machines. You have to sign the InfoPath Web-Enabled template with a domain trusted certificate. Once you do this you should upload the new signed template, then you should be able to open the form without exception.

Hope this helps,

Jay.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top