简体   繁体   中英

run-time error '429' activex component can't create object

I've created a simple application .net Class that converts an excel spreadsheet into a pdf file. I then get an Excel 2007 application to call this dll which works fine on my development machine.

However, when I deploy it on to a Vista machine, that has both the .net framework and Excel 2007, I get this error:

run-time error '429' activex component can't create object

Even though I am an administrator on the machine, I cannot seem to put signed .net dlls into the GAC.

Can someone please help me resolve this?

This is how I'm calling .net tlb file from Excel 2007.

Sub TestSub()<br>
 &nbsp;Dim printLibraryTest As PrintLibrary.Print<br>
 &nbsp;Set printLibraryTest = New PrintLibrary.Print <br>
 &nbsp; printLibraryTest.ConvertExcelToPdf <br>
End Sub <br>

This is .net library below.

using System;<br>
using System.Collections.Generic;<br>
using System.Runtime.InteropServices;<br>
using System.Text;<br>
using Microsoft.Office.Interop.Excel;<br><br>

namespace PrintLibrary<br>
{<br>
    [ClassInterface(ClassInterfaceType.None)]<br>
    [Guid("3d0f04d2-9123-48e0-b12f-6c276ff2281b")]<br>
    [ProgId("PrintLibrary.Test")]<br>
    public class Print<br>
    {      <br>
        public void ConvertExcelToPdf(string inputFile,string outputFile)    <br>
        {    <br>
          &nbsp;&nbsp;  ApplicationClass excelApplication = new ApplicationClass();    <br>
          &nbsp;&nbsp;   Workbook excelWorkBook = null;    <br>
          &nbsp;&nbsp;  string paramSourceBookPath = inputFile;    <br>
          &nbsp;&nbsp;   object paramMissing = Type.Missing;    <br>

          string paramExportFilePath = outputFile;
          XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;
          XlFixedFormatQuality paramExportQuality =
          XlFixedFormatQuality.xlQualityStandard;
          bool paramOpenAfterPublish = false;
          bool paramIncludeDocProps = true;
          bool paramIgnorePrintAreas = true;
          object paramFromPage = Type.Missing;
          object paramToPage = Type.Missing;


            try
            {
                // Open the source workbook.
                excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPath,
                paramMissing, paramMissing, paramMissing, paramMissing,
                paramMissing, paramMissing, paramMissing, paramMissing,
                paramMissing, paramMissing, paramMissing, paramMissing,
                paramMissing, paramMissing);

                // Save it in the target format.
                if (excelWorkBook != null)
                    excelWorkBook.ExportAsFixedFormat(paramExportFormat,
                    paramExportFilePath, paramExportQuality,
                    paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,
                    paramToPage, paramOpenAfterPublish,
                    paramMissing);
            }
            catch (Exception ex)
            {
                // Respond to the error.
            }

Finally

            {
                // Close the workbook object.
                if (excelWorkBook != null)
                {
                    excelWorkBook.Close(false, paramMissing, paramMissing);
                    excelWorkBook = null;
                }

                // Quit Excel and release the ApplicationClass object.
                if (excelApplication != null)
                {
                    excelApplication.Quit();
                    excelApplication = null;
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }  
        }
    }
}

One year later ...

Is it possible that this may be due to the same reason than this : http://support.microsoft.com/kb/313984/en-us

The error occurs because the target computer is missing the license information for the control objects that are used in the application [...] This would generate a setup package that contains the correct version of the Winsock control. However, the license key for the control will not be compiled into the application unless an instance of the control is placed on a form. When you try to instantiate the objects at run time, the application has no way to provide the license key, and the code will fail. For example, the following code will run properly at design time, but will fail at run time on computers that do not have Visual Basic installed.

There seems to be a relation to your case here :

  • Same error number and message
  • Happens at the same time : when you deploy to a non dev machine

The workaround seems to be placing the control on a form.


Check out this article too : Run-time error '429'

Excel 2007 VB Script Run-time Error 429 when execute:

Set objFSO = CreateObject("Scripting.FileSystemObject").

Solution:

  1. Check "My Documents" location it pointed.
  2. Check Excel Option save location.
  3. Run "regsvr32 scrrun.dll".

References:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM