繁体   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