<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Form inheriting from DLL</title><link>https://www.infopathdev.com:443/forums/thread/47097.aspx</link><pubDate>Thu, 17 Sep 2009 13:19:45 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:47097</guid><dc:creator>nmoran</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/47097.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=47097</wfw:commentRss><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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. &lt;/p&gt;So, to ensure all this is possible, we created a Strong Named DLL in VS2008 (also tried VS2005) with the following: &lt;br /&gt;Public Class MyClass&lt;br /&gt;Inherits Microsoft.Office.InfoPath.XmlFormHostItem&lt;br /&gt;Public Sub New(ByVal initArgs As System.AddIn.Contract.Collections.IRemoteArgumentArrayContract)&lt;br /&gt;MyBase.New(initArgs)&lt;br /&gt;End Sub&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;Then we created a simple InfoPath form with the following in FormCode.Designer.vb:&lt;br /&gt;_&lt;br /&gt;Partial Public NotInheritable Class FormCode&lt;br /&gt;Inherits MyDLL.MyClass&lt;br /&gt;&lt;br /&gt;‘all the other stuff generated in this file...&lt;br /&gt;&lt;br /&gt;And the following in FormCode.vb&lt;br /&gt;Public Class FormCode&lt;br /&gt;Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup&lt;br /&gt;AddHandler EventManager.FormEvents.Loading, AddressOf FormEvents_Loading&lt;br /&gt;End Sub&lt;br /&gt;Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)&lt;br /&gt;End Sub&lt;br /&gt;End Class&lt;br /&gt;
&lt;p&gt;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:&lt;br /&gt;There is an error in the InternalStartup method of form code.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;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)&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item></channel></rss>