This error most likely occurs if the .NET framework was installed after InfoPath was. Office 2007 does not by default install all required components for InfoPath 2007 to work with managed code.
To install the PIA:
1. Navigate to the InfoPath Help menu and select Detect and Repair for InfoPath 2003 or Office Diagnostics for InfoPath 2007 to repair your InfoPath installation.
2. Download and install the Primary Interop Assemblies (PIA) for your version of Office:
Office 2003: http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-
8ba0-d36d67e0f4ad&displaylang=en
Office 2007: http://www.microsoft.com/downloads/details.aspx?FamilyID=59daebaa-bed4-4282-
a28c-b864d8bfa513&DisplayLang=en
3. Run the InfoPath / Office setup again.
Installing the PIA does not always work. In those stubborn cases, the solution is to go thru the Office installation and make sure to install all components of Infopath.