Can't find a clear answer out there so thought I'd ping the group... I've simplified the scenario as far as I can for this one...
Scenario:
InfoPath 2013 Forms Services. Publishing directly to Form Library. Works fine if either Data connections exist, or simple custom code exists (i.e. on form load set the value of a textbox on the form to "Hello From Code Behind".
HOWEVER, if you put a Data connection (ListService from same site retrieve values from a SPList and display them in a drop down box on the form) on the same form as simple code behind and publish, you get an error on form load:
"Warning. 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.
when you look up the correlation ID in the logs...Error details points to sandbox code service not being able to load type Microsoft.SharePoint.Administration.SPService... see below
04/19/2014 14:05:24.10 w3wp.exe (0x21A8) 0x3088 SharePoint Foundation Sandboxed Code Service ajrl9 High - UserCodeExecutionProxy call failed with solution code itself. ServiceUrl: tcp://server:32846/SPUCExecutionHost; Microsoft.SharePoint.UserCode.SPUserCodeSolutionExecutionFailedException: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: Could not load type 'Microsoft.SharePoint.Administration.SPService' from assembly 'Microsoft.SharePoint, Version=15.900.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. --->
Any thoughts? I know I can fix this by publishing to Central Admin first and then activating to site collection... but why do each of these work separately but not together?