Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I know how to upload the published xsn InfoPath form, but when I try to open it, the form can't find its code behind assembly dll. Does anyone know how to add that? I know it gets put in hive 14 folder at FT-01-\version #.

Do I have to manually find that folder and place the dll in there? Or is there a way I can upload the dll along with the form?

Here is my code so far:

            FormsService localFormsService;
            SPFarm localFarm = SPFarm.Local;

            try
            {
                FormTemplate temp = new FormTemplate();
                localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);

                localFormsService.FormTemplates.UpgradeFormTemplate(@"C:\PublishedForms\My Form.xsn",  FormTemplateCollection.UpgradeType.Overwrite);                    

                SPWebApplication webApplication = SPContext.Current.Site.WebApplication;
                SPSiteCollection siteCollections = webApplication.Sites;

                FormTemplateCollection fCol = localFormsService.FormTemplates;

                foreach (FormTemplate f in fCol)
                {
                    if (f.Name == "My Form")
                        f.Activate(siteCollections[0]);
                }                    
            }
            catch (Exception ex) { }

Here is the error I get when I try to open the form from my site collection.

"Could not load file or assembly 'file:///C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\FT-01-6c9edb80-4be2-73f2-3ef4-bb647484b323\MyForm.dll' or one of its dependencies.

share|improve this question
add comment

2 Answers

The code behind is contained in the xsn file, which is also a CAB file.

share|improve this answer
    
That's what I thought but I am still getting a "Could not load file or assembly 'file:///C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\FT-01-6c9edb80-4be2-73f2-3ef4-bb647484b323\MyFor‌​m.dll' or one of its dependencies. The system cannot find the file specified. " Error when I try to open it –  Meyer Denney Sep 13 '12 at 20:36
add comment

Your code contains server-side code which will run only in Infopath web browser opened in browser, i.e. through IPFS Sharepoint Server Infopath Form Service.

The problem is that Infopath browser form may be tried to be opened both in browser and in Infopath client/Filler. The latter is default behavior which you must avoid/prevent.

Though, in my experience even after changing in form library Advanced Settings the Opening Documents in the Browser from default "Use the server default (Open in the client application)" to "Open in the Browser",

Opening Documents in the Browser

as well as marking "Enable this form to be filled out by using a browser" in Publishing wizard of Infopath browser form template

"Enable this form to be filled out by using a browser" in in Publishing wizard of Infopath browser form template

the Infopath Web Browser Form can still be explicitly tried to be opened in client through context menu:

Edit in browser - Edit in Microsoft Infopath context choices

as well as the links to existing XML data forms or "Add new document" in a sharepoint form library

"Add new document" in a sharepoint form library

are still being opened in client/filler in Internet Explorer (and in browser if opened, for example, in Mozilla Firefox).

I am not quite sure how to control this behavior.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.