InfoPath exception occurred during loading of business logic for central published form

 

This is a really strange one.  I can’t fully explain it, but I totally stumbled upon a workaround.

  1. I publish an InfoPath form with domain trust through central administration.  It pushed my form into a form template for my site http://myserver/ 
  2. I try to create a new form in a forms library based on that published template.
  3. I get an error when I try to load the new form in Forms Service:

There are various errors in the event log and the log.  Event Log says:

An exception occurred during loading of business logic. (User: SHAREPOINTGURUS\john.liu, Form Name: MyForm, IP: , Request: http://myserver/_layouts/FormServer.aspx?XsnLocation=http://myserver/FormServerTemplates/MyForm.xsn&SaveLocation=http://myserver/Forms&Source=http://myserver/Forms/Forms/AllItems.aspx&DefaultItemOpen=1, Form ID: urn:schemas-microsoft-com:office:infopath:MyForm:-myXSD-2010-11-14T21-46-49, Type: FileNotFoundException, Exception Message: Could not load file or assembly 'file:///C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\FT-01-3032e4bd-bd7f-61d1-42aa-f9786a132aee\MyForm.dll' or one of its dependencies. The system cannot find the file specified.)

 

In you drill into the various errors you’ll see actually there appears to have been an error during the deployment of the form, thus the form actually haven’t been deployed properly.  What’s really strange though, is this fix that I came across and can’t explain.

 

Fix?

  1. Go to Library Settings for http://myserver/Forms/
  2. Since you are using central admin deployed forms – you should be using Content Types, I only have Forms content type here.  Click that.
  3. Then click Advanced Settings
  4. Check the Form content type’s Form Template URL in the advanced settings.  In my case it is still pointing to the file in /Form Templates/
  5. Don’t change anything - Click OK
  6. Suddenly I can create new forms again in /Forms/

SharePoint's Silverlight webpart defaults to WindowlessMode

 

Because SharePoint’s Silverlight webpart defaults to windowless="true", there are some features of Silverlight that won’t work as you’d expect out of the box.

  • Drag and drop events
  • Transparency
  • Overlay DIV

By default, it renders something like this:

<object id="SilverlightObjectTag_xxx" data="data:application/x-silverlight-2," type="application/x-silverlight-2" style="display:block" height="100%" width="100%" class="ms-dlgDisable">

<param name="source" value="/sites/Home/Style Library/SilverlightCamera.xap"/>

<param name="onerror" value="…" />

<param name="background" value="white" />

<param name="initParams" value="…" />

<param name="windowless" value="true" />

 

Luckily, the SharePoint team provides an easy property to override this value.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.silverlightwebpart.windowlessmode.aspx

When packaging your Silverlight .webpart file, configure the XML to set the WindowlessMode property to false.

<?xml version="1.0" encoding="utf-8"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name=
"Microsoft.SharePoint.WebPartPages.SilverlightWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">Silverlight Metro UI Web Part</property>
        <property name="Description" type="string">Metro UI.</property>
        <property name="Url" type="string">~sitecollection/Style Library/Metro.Demo.xap</property>
        <property name="Height" type="int">800</property>
       <property name="WindowlessMode" type="bool">false</property>
      </properties>
    </data>
  </webPart>
</webParts>

 

Then the rendered HTML will have the value set appropriately, and Silverlight drag and drop events will work happily again, in SharePoint.

InfoPath 2010 COM Add-ins not available in Form Design

In a previous life, I wrote Outlook and Word Add-ins to automate/extend those office apps.

I was looking up whether there’s a way to script or create a COM Add-In to InfoPath during Form Design, so we can do 1-click refresh/update all secondary data connection offline data, without manually clicking wizards. Or even hook into some sort of OnPublishing event so it does the update automatically when you are about to Publish the form.

INTERESTING…

You can write COM Add-in for InfoPath 2010! Apparently new in 2010.

BAD!

Can’t extend the InfoPath form designer. Can only extend the editing. But that means you have more deployment issues.

http://msdn.microsoft.com/en-us/library/aa946869.aspx

How to: Create a COM Add-in to Add Custom Features to InfoPath

Office 2010

Microsoft InfoPath 2010 supports COM Add-ins for extending the form editing user experience. Although support for COM Add-ins was first added in InfoPath 2010, other Office applications such as Microsoft Office Word and Microsoft Office Excel have supported COM add-ins since Office 2000.

COM Add-in support in InfoPath is available for the form editing environment. The form design environment cannot be extended by using COM Add-ins.

Did MS ran out of time?

SharePoint 2010 WCF HelloWorld Service and InfoPath

Was looking for a quick tutorial for creating a Custom WCF Service for SharePoint 2010.  For some reason couldn’t find one, so I sat down and try it out and decide to write out a few simple steps.

Use CKSDev

http://cksdev.codeplex.com/ version 1.2 included new Visual Studio Item templates for creating WCF services and makes this whole process a breeze.  Thanks to Charlie Holland’s hardwork.

 

Build Solution

  1. Create New Blank VS.NET SharePoint Solution “HelloWorldWCF”
  2. WCF Service has to be a Farm Solution.
  3. Add New Item, and select WCF Service (CKSDev)image
  4. The created Service includes a stub method that returns a string.

    [BasicHttpBindingServiceMetadataExchangeEndpoint]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class HelloWorldWCFService : IHelloWorldWCFService
    {
        // To test this service, use the Visual Studio WCF Test client
        // set the endpoint to http://<Your server name>/_vti_bin/HelloWorldWCF/HelloWorldWCFService.svc/mex
        public string HelloWorld()
        {
            return "Hello World from WCF and SharePoint 2010";
        }
    }
  5. Compile solution and Deploy to server

Verify Service

  1. The service is deployed to /_vti_bin/HelloWorldWCF/HelloWorldWCFService.svc
  2. The endpoint is at http://server/_vti_bin/HelloWorldWCF/HelloWorldWCFService.svc/mex
  3. Browse it with your browser you should see:

image

 

Connect Via InfoPath

  1. Create an External Connection
  2. Select SOAP Service, use the /mex endpoint
  3. You may be asked to authenticate with the service
  4. Select the method

    image
  5. Cache, and Retrieve when form load as necessary.

    image
  6. Bind the result of the web service to a textbox

    image

 

Test in InfoPath

  1. Preview the InfoPath form

    image