簡體   English   中英

運行時錯誤“ 429” activex組件無法創建對象

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

我創建了一個簡單的應用程序.net類,它將一個Excel電子表格轉換為pdf文件。 然后,我得到一個Excel 2007應用程序來調用此dll,該dll在我的開發計算機上正常運行。

但是,當我將其部署到同時具有.net框架和Excel 2007的Vista計算機上時,出現此錯誤:

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

即使我是計算機的管理員,我似乎也無法將簽名的.net dll放入GAC。

有人可以幫我解決這個問題嗎?

這就是我從Excel 2007調用.net tlb文件的方式。

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

這是下面的.net庫。

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.
            }

最后

            {
                // 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();
            }  
        }
    }
}

一年之后 ...

是否可能是由於與以下原因相同的原因: http : //support.microsoft.com/kb/313984/en-us

發生錯誤是因為目標計算機缺少應用程序中使用的控件對象的許可證信息。這將生成包含正確版本的Winsock控件的安裝程序包。 但是,除非將控件的實例放在窗體上,否則控件的許可證密鑰將不會編譯到應用程序中。 當您嘗試在運行時實例化對象時,應用程序無法提供許可證密鑰,並且代碼將失敗。 例如,下面的代碼將在設計時正常運行,但在未安裝Visual Basic的計算機上,將在運行時失敗。

似乎與您的案件有關:

  • 錯誤號和消息相同
  • 同時發生:當您部署到非開發機器時

解決方法似乎是將控件放在窗體上。


也查看此文章: 運行時錯誤“ 429”

執行時Excel 2007 VB腳本運行時錯誤429:

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

解:

  1. 檢查它指向的“我的文檔”位置。
  2. 檢查Excel選項的保存位置。
  3. 運行“ regsvr32 scrrun.dll”。

參考文獻:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM