com-interop

unable to cast COM object of type 'microsoft.Office.Interop.Excel.ApplicationClass' to 'microsoft.Office.Interop.Excel.Application'"

你说的曾经没有我的故事 提交于 2019-11-26 05:37:25
问题 This is my first attempt to capture some data from excel from within one C# console application. I get the error \"unable to cast COM object of type \'microsoft.Office.Interop.Excel.ApplicationClass\' to \'microsoft.Office.Interop.Excel.Application\'\". This code used the \'Microsoft Excel 12.0 Object Library\' , and I gave reference to Microsoft.Office.Interop.Excel. Still, I could not get over this error - which I believe has its own quick solution. I digged a little bit this site and came

Fastest way to interface between live (unsaved) Excel data and C# objects

荒凉一梦 提交于 2019-11-26 05:18:57
问题 I want to know what the fastest way is of reading and writing data to and from an open Excel workbook to c# objects. The background is that I want to develop a c# application that is used from Excel and uses data held in excel. The business logic will reside in the c# application but the data will reside in an Excel workbook. The user will be using Excel and will click a button (or do something similar) on the excel workbook to initiate the c# application. The c# application will then read

Turn a simple C# DLL into a COM interop component

匆匆过客 提交于 2019-11-26 04:36:48
问题 How do I make a C# DLL into a COM interop DLL that can be consumed by a VB6 application? 回答1: This is the answer I wanted to find in StackOverflow but couldn't. It turns out to be fairly easy to turn a simple C# dll into a COM dll. To create the C# dll Create a solution with a C# class project. The class should have an interface for the properties/methods and an interface for the events. Assign GUID attributes to the class and interfaces as described in MSDN - Example COM Class (C#

How do I properly clean up Excel interop objects?

旧街凉风 提交于 2019-11-26 03:13:05
问题 I\'m using the Excel interop in C# ( ApplicationClass ) and have placed the following code in my finally clause: while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { } excelSheet = null; GC.Collect(); GC.WaitForPendingFinalizers(); Although this kind of works, the Excel.exe process is still in the background even after I close Excel. It is only released once my application is manually closed. What am I doing wrong, or is there an alternative to ensure interop

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154

。_饼干妹妹 提交于 2019-11-26 00:27:23
问题 I developed a Windows service using C#.NET to generate PDF report. To generate PDF file I am using a third party dll. The application is running in my Windows XP platform. When I deployed the service in Windows Server 2008 64 bit version, I got this error: Retrieving the COM class factory for component with CLSID {46521B1F-0A5B-4871-A4C2-FD5C9276F4C6} failed due to the following error: 80040154. I registered the DLL using the regsvr32 command. I able to see this CLSID in the registry. But the

Clean up Excel Interop Objects with IDisposable

妖精的绣舞 提交于 2019-11-25 21:55:34
问题 In my company the common way to release Excel Interop Objects is to use IDisposable the following way: Public Sub Dispose() Implements IDisposable.Dispose If Not bolDisposed Then Finalize() System.GC.SuppressFinalize(Me) End If End Sub Protected Overrides Sub Finalize() _xlApp = Nothing bolDisposed = True MyBase.Finalize() End Sub where _xlApp was created in the constructor the following way: Try _xlApp = CType(GetObject(, \"Excel.Application\"), Excel.Application) Catch e As Exception _xlApp