运行时错误“429”activex组件不能创build对象

我创build了一个简单的应用程序.net类,将Excel电子表格转换为PDF文件。 然后我得到一个Excel 2007应用程序来调用这个DLL在我的开发机器上工作正常。

但是,当我将它部署到一台Vista机器,它有.net框架和Excel 2007,我得到这个错误:

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

尽pipe我是机器上的pipe理员,但似乎无法将签名的.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

发生该错误的原因是目标计算机缺less应用程序中使用的控制对象的许可证信息[…]这将生成一个包含Winsock控件的正确版本的安装程序包。 但是,控件的许可证密钥将不会编译到应用程序中,除非将控件的实例放置在窗体上。 当您尝试在运行时实例化对象时,应用程序无法提供许可证密钥,代码将失败。 例如,下面的代码将在devise时正确运行,但是在没有安装Visual Basic的计算机上运行时会失败。

这里似乎与你的情况有关系:

  • 相同的错误号码和消息
  • 发生在同一时间:当你部署到非开发机器

解决方法似乎是将控件放在窗体上。


看看这篇文章: 运行时错误'429'

执行时Excel 2007 VB脚本运行时错误429:

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

解:

  1. 选中它指向的“我的文档”位置。
  2. 检查Excel选项保存位置。
  3. 运行“regsvr32 scrrun.dll”。

参考文献: