Form inheriting from DLL - InfoPath Dev
in

InfoPath Dev

Form inheriting from DLL

Last post 09-17-2009 06:19 AM by nmoran. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 09-17-2009 06:19 AM

    • nmoran
    • Not Ranked
    • Joined on 09-16-2009
    • Posts 3

    Form inheriting from DLL

    We have about 60 government documents that we are converting to InfoPath and publishing via the web through our SharePoint server for employees to fill out.

    Each document needs similar info like first name, last name, address, etc. but has its own unique spin on how the data is presented. We have been tasked with pre-populating this info via a webservice and performing some other proprietary operations. To aid in this, we are attempting to encapsulate our code in a DLL, have the form’s FormCode class inherit from it, and override methods where we set things proprietary to each form.

    So, to ensure all this is possible, we created a Strong Named DLL in VS2008 (also tried VS2005) with the following:
    Public Class MyClass
    Inherits Microsoft.Office.InfoPath.XmlFormHostItem
    Public Sub New(ByVal initArgs As System.AddIn.Contract.Collections.IRemoteArgumentArrayContract)
    MyBase.New(initArgs)
    End Sub
    End Class

    Then we created a simple InfoPath form with the following in FormCode.Designer.vb:
    _
    Partial Public NotInheritable Class FormCode
    Inherits MyDLL.MyClass

    ‘all the other stuff generated in this file...

    And the following in FormCode.vb
    Public Class FormCode
    Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
    AddHandler EventManager.FormEvents.Loading, AddressOf FormEvents_Loading
    End Sub
    Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)
    End Sub
    End Class

    All this runs great in InfoPath’s preview mode on development machines, so we installed the DLL into the GAC on the SharePoint server, but when we try to upload the form template in Central Administration on the SharePoint server we get the following error:
    There is an error in the InternalStartup method of form code.


    We can successfully upload the form template to SharePoint and run it correctly if the code is moved out of the DLL and placed in a .vb file local to the form’s code. (i.e. Partial Public NotInheritable Class FormCode Inherits MyLocalClass)

    We have also created another Strong Named DLL and uploaded an InfoPath form template on the server that interacts with it in the GAC. This works great, but the FormCode is not inheriting which seems to be the issue.

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.