Object reference not set to an instance of an object while uploading InfoPath Form

 

I have a full trusted InfoPath form that was OK in MOSS 2007 and it was also OK to import from the exported cab files with SharePoint 2010 RTM. But it throws the following error after SP2010 SP1  when I tried to upload the same InfoPath form:

System.NullReferenceException: Object reference not set to an instance of an object.  
at Microsoft.Office.InfoPath.Server.Converter.DetectUnsupportedNamespaces.VerifyNamespace(String ns, String nodeName, ICollection`1 problems)   
at Microsoft.Office.InfoPath.Server.Converter.BusinessLogicScanner.<>c__DisplayClass2.<Analyze>b__1(MethodBase method)   
at Microsoft.Office.InfoPath.Server.Converter.BusinessLogicScanner.VisitMethod(MethodBase method, MethodInfoVisitor methodVisitor)   
at Microsoft.Office.InfoPath.Server.Converter.BusinessLogicScanner.VisitBody(MethodBase method, MethodInfoVisitor methodVisitor)   
at Microsoft.Office.InfoPath.Server.Converter.BusinessLogicScanner.VisitBody(MethodBase method, MethodInfoVisitor methodVisitor)   
at Microsoft.Office.InfoPath.Server.Converter.BusinessLogicScanner.VisitBody(MethodBase method, MethodInfoVisitor methodVisitor)   
at Microsoft.Office.InfoPath.Server.Converter.BusinessLogicScanner.VisitMethods(Type mainType, MethodInfoVisitor methodVisitor)   
at Microsoft.Office.InfoPath.Server.Converter.BusinessLogicScanner.Analyze(Type mainType, List`1 rules)   
at Microsoft.Office.InfoPath.Server.SolutionLifetime.BusinessLogicLoader.VerifyUsingFxCop(Assembly rootAssembly)   
at Microsoft.Office.InfoPath.Server.SolutionLifetime.BusinessLogicLoader.Microsoft.Office.InfoPath.Server.SolutionLifetime.ISolutionComponent.Parse(XPathNavigator documentClassNode, XmlNamespaceManager solutionNamespaceManager, ConversionContext context)   
at Microsoft.Office.InfoPath.Server.SolutionLifetime.Solution.ParseManifest(ConversionContext context, XPathNavigator node)   
at Microsoft.Office.InfoPath.Server.SolutionLifetime.Solution.LoadFromXsn(ConversionContext context, SolutionCabinet solutionCabinet, SolutionIdentity solutionId)   
at Microsoft.Office.InfoPath.Server.SolutionLifetime.Solution.<>c__DisplayClass2.<ConstructFromXsnFile>b__0()   
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)   
at Microsoft.Office.Server.Diagnostics.ULS.SendWatsonOnExceptionTag(UInt32 tagID, ULSCatBase categoryID, String output, Boolean fRethrowException, TryBlock tryBlock, CatchBlock catchBlock, FinallyBlock finallyBlock)   
at Microsoft.Office.InfoPath.Server.SolutionLifetime.Solution.ConstructFromXsnFile(ConversionContext context, SolutionCabinet solutionCabinet, SolutionIdentity solutionId)   
at Microsoft.Office.InfoPath.Server.Converter.ConversionAppDomain.OperationRunner.ExecuteConversion(ConversionContext& context, SolutionCabinet solutionCabinet, SolutionIdentity solutionId, Boolean executeVerification)   
at Microsoft.Office.InfoPath.Server.Converter.ConversionAppDomain.OperationRunner.ExecuteConversion(ConversionContext& context, SolutionCabinet solutionCabinet, SolutionIdentity solutionId, Boolean executeVerification)   
at Microsoft.Office.InfoPath.Server.Converter.ConversionAppDomain.ExecuteInRemote(ConversionContext context, AppDomain domain, SolutionCabinet solutionCabinet, SolutionIdentity solutionId)   
at Microsoft.Office.InfoPath.Server.Converter.ConversionAppDomain.<>c__DisplayClass4.<TryRunConversion>b__0()   
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)   
at Microsoft.Office.Server.Diagnostics.ULS.SendWatsonOnExceptionTag(UInt32 tagID, ULSCatBase categoryID, String output, Boolean fRethrowException, TryBlock tryBlock, CatchBlock catchBlock, FinallyBlock finallyBlock)   
at Microsoft.Office.InfoPath.Server.Converter.ConversionAppDomain.TryRunConversion(ConversionContext context, SolutionCabinet solutionCabinet, SolutionIdentity solutionId, Byte[] solutionData, WspSolutionInfo wspSolution)   
at Microsoft.Office.InfoPath.Server.Converter.ConversionAppDomain.RunConversion(ConversionContext context, SolutionCabinet solutionCabinet, SolutionIdentity solutionId)   
at Microsoft.Office.InfoPath.Server.Util.InstalledSolutions.<>c__DisplayClass7.<VerifyUnpackedSolution>b__6()   
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)   
at Microsoft.Office.Server.Diagnostics.ULS.SendWatsonOnExceptionTag(UInt32 tagID, ULSCatBase categoryID, String output, Boolean fRethrowException, TryBlock tryBlock, CatchBlock catchBlock, FinallyBlock finallyBlock)   
at Microsoft.Office.InfoPath.Server.Util.InstalledSolutions.VerifyUnpackedSolution(SolutionCabinet solutionCabinet, String originalFileName, ConversionContext context, ConverterLog& outputConverterLog, Byte[]& outputConvertedData)   
at Microsoft.Office.InfoPath.Server.Util.InstalledSolutions.VerifySolution(String absoluteLocalPath, ConversionContext context, ConverterLog& converterLog, Byte[]& convertedData)   
at Microsoft.Office.InfoPath.Server.Administration.FormTemplateCollection.VerifyFormTemplateInternal(String solutionPath, ConverterLog& converterLog)   
at Microsoft.Office.InfoPath.Server.Administration.FormTemplateCollection.TryAdd(String solutionPath, ConverterLog& converterLog)   
at Microsoft.Office.InfoPath.Server.ApplicationPages.UploadFormTemplatePage.<>c__DisplayClass1.<ButtonOkClick>b__0(String sourceName)   
at Microsoft.Office.InfoPath.Server.ApplicationPages.UploadFormTemplatePage.HandleFiles(HandleFile fileHandler)   
at Microsoft.Office.InfoPath.Server.ApplicationPages.UploadFormTemplatePage.ButtonOkClick(Object sender, EventArgs e)   
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)   
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)   
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)   
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

In the troubleshooting process, I copied this InfoPath to a fresh SharePoint farm and tried to upload it and it verified OK but give me a list of referenced assemblies that were missing. I added the missing assembly to GAC and the above error showed up again. So there is must be something special about the assembly – looked at the source code and found out that the public class used by InfoPath form code does not have namespace. Added the namespace and everything works fine now.