Tag: comexception

与Excel中的interopServices C#COMException

我在一些机器上安装我的程序时遇到了一个非常恼人的问题,我已经开发了一个C#应用程序,一切正常,当然我在另一台机器上testing了它,没有任何问题,但是当我在客户端机器上安装时,会出现以下问题: System.Runtime.InteropServices.COMException(0x800A03EC):来自HRESULT:0x800A03EC在Microsoft.Office.Interop.Excel.Range System.RuntimeType.ForwardCallToInvokeMember(stringmemberName,BindingFlags标志,对象目标,Int32 [] aWrapperTypes,MessageData&msgData) .set__Default(对象RowIndex,对象ColumnIndex,对象)在SchoolMgmt.certificate_succession.sum_operation() 当程序与Excel,Office微软(我试图安装另一个Office版本没有成功)沟通。 我已经search了很多的解决scheme,但没有任何作品,因为它声称这个问题只是在以下path权限问题 C:\ Windows \ System32 \ config \ SystemProfile 为什么程序在我的testing机上顺利而顺利地运行,而不是在我的客户端呢,真的让我发疯了! 任何build议请。

C#Microsoft.Office.Interop.Excel.Range.CopyPicture在一些计算机上工作,但不在其他人上

我试图将所选Excel范围的图片复制到剪贴板,并在我的GUI上显示该位图。 我有这个方法来获取位图: using Excel = Microsoft.Office.Interop.Excel; public static Bitmap CopyPicture(ref Excel.Range range) { System.Threading.Thread.Sleep(1000); //Google told me… range.Select(); //…that these lines are possible fixes. range.Copy(); //They aren't. try { range.CopyPicture(Excel.XlPictureAppearance.xlScreen, Microsoft.Office.Interop.Excel.XlCopyPictureFormat.xlBitmap); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } IDataObject data = Clipboard.GetDataObject(); if (data != null) { if (data.GetDataPresent(DataFormats.Bitmap)) { Bitmap map = (Bitmap)data.GetData(DataFormats.Bitmap, true); […]

当我在IIS中托pipe我的DotNet应用程序时Excel文件不打开

我有我的DotNet应用程序,我打开Excel文件通过从数据库获取pathbutton单击,它工作正常,但是当我在IIS中托pipe我的应用程序,然后我得到以下exception – System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad) 请帮忙…

COMException C#Microsoft.Office.Interop.Excel

我想解决我遇到的一个COMException的问题。 这是我的代码: 工作簿原始=新工作簿(结果[0])中出现错误; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using MahApps.Metro.Controls; using MahApps.Metro; using Microsoft.Win32; using System.Windows.Forms; using System.Data; using Microsoft.Office.Interop.Excel; namespace KPI_Generator_v3 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> […]

分配给Excel.Application.ActivePrinter时发生COMException

我有一个函数,我通过一个Microsoft.Office.Interop.Excel.Application实例。 该function使用Windows内置的传真打印机或Microsoft XPS Document Writer将文件保存为tiff图像。 但是,当我尝试分配给应用程序的ActivePrinter属性时,会引发一个COMException,并显示以下消息: 来自HRESULT的exception:0x800A03EC 代码如下: 'Save the current default printer Dim strDefaultPrinter As String = excelApp.ActivePrinter 'Assign printer string constant to ActivePrinter – throws exception excelApp.ActivePrinter = FAX_PRINTER excelApp.ActiveWorkbook.PrintOutEx(, , , , , True, "c:\RestOfFilePath…") ' Print to file = true 'Reset the default printer excelApp.ActivePrinter = strDefaultPrinter 所使用的打印机都被确认为安装在registry中。 一个类似的function,需要一个Word应用程序类工作正常。 我相当新的COM相关的东西,我有一种感觉,这可能只是我玩的相关的愚蠢无知,但我可以find几乎没有任何关于此search谷歌/ stackoverflow,除了一个或两个旧的,未答复线程。 […]

Excel文件上的C#multithreading访问

我正在编写一个multithreading的C#应用​​程序,它提供了一些Excel文件的统计信息。 我通过以下代码打开文件: private static Excel.Application excelApp = new Excel.Application(); private static Excel.Workbook workbook = excelApp.Workbooks.Open(path); private static Excel.Worksheet worksheet = workbook.ActiveSheet; private static Excel.Range range = worksheet.UsedRange; private static int totalColumns = worksheet.UsedRange.Columns.Count; 为了从列中收集数据,我使用了每列一个线程。 for (int columnCount = 1; columnCount <= /*range.Columns.Count*/totalColumns; columnCount++) { Thread worker = new Thread(printSpread); worker.Start(columnCount); } 我得到HRESULT:0x800A01A8如果我不在每个线程中启动一个新的Excel应用程序错误。 我的问题是,我必须这样做还是有机会只使用一个Excel应用程序? 我认为,从多个线程访问仅来自一个应用程序的数据存在问题,这将解释COMexception。 感谢您的时间和帮助。

Excel应用程序在设置宽度方面有一个例外

我想通过WPF项目来控制Excel应用程序。 var xla = new Microsoft.Office.Interop.Excel.Application(); xla.Width = 400; // This line is throwing the below exception. 它几次工作正常,几天后,同一行给出了一个例外如下所示。 注销并login到系统暂时修复问题。 System.Runtime.InteropServices.COMException was unhandled HResult=-2146827284 Message=Exception from HRESULT: 0x800A03EC Source=Microsoft.Office.Interop.Excel ErrorCode=-2146827284 StackTrace: at Microsoft.Office.Interop.Excel.ApplicationClass.set_Width(Double RHS) at EmbedExcel1.Form1.button1_Click(Object sender, EventArgs e) in d:\Test Projects\EmbedExcel1\EmbedExcel1\Form1.cs:line 27 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons […]

区分Excel Interop操作引发的exception

我正在使用Microsoft.Office.Interop.Excel库从C#应用程序中将数据导出到Excel。 调用sheet.Cells[currentRow, 1])与一个无效的currentRow值,导致System.Runtime.InteropServices.COMException消息: "Exception from HRESULT: 0x800A03EC" 和ErrorCode -2146827284 但是,我已经收到完全相同的错误代码,订购Excel以保存到写保护文件。 有没有办法区分从Excel接收到的COMExceptions,所以我可以相应地处理它们? 我宁愿不把用户留在“使用Excel工作时出错,对不起,太糟糕了”。

在ASP.NET中dynamic生成Excel文档时出现“许可证过期”错误

任何熟悉以下错误的人? 当我运行我的web应用程序从本地机器生成一个dynamic的Excel文档时,它工作正常,但是当服务器上调用同一段代码时,我得到下面的错误。 这似乎是一个权限问题,因为它在我的机器上,但不是服务器,但我不知道从哪里开始,以查明问题。 任何指导/帮助非常感谢! Server Error in '/' Application. ——————————————————————————– This command is unavailable because the license to use this application has expired. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception […]

在Excel VSTO中,如何检查工作表是否属于已closures的工作簿?

如果我有Worksheet的引用,并closures它的父Workbook ,引用不会消失。 但我无法弄清楚我应该如何检查以确保这些表不存在。 检查null不起作用。 例: Workbook book = Globals.ThisAddIn.Application.ActiveWorkbook; Worksheet sheet = (Worksheet)book.Worksheets[1]; // Get first worksheet book.Close(); // Close the workbook bool isNull = sheet == null; // false, worksheet is not null string name = sheet.Name; // throws a COM Exception 这是我尝试访问工作表时遇到的exception情况: System.Runtime.InteropServices.COMException was caught HResult=-2147221080 Message=Exception from HRESULT: 0x800401A8 Source=MyProject ErrorCode=-2147221080 StackTrace: […]