Questions tagged [com-interop]

COM interop is the layer that allows .NET assemblies to communicate with standard COM objects and libraries.

COM interop is the layer that allows .NET assemblies to communicate with standard COM objects and libraries by exposing it's own objects or wrapping external COM objects.

Resources:

1845 questions
804
votes
43 answers

How do I properly clean up Excel interop objects?

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 =…
HAdes
  • 16,713
  • 22
  • 58
  • 74
305
votes
18 answers

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

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…
gopal
  • 3,681
  • 5
  • 24
  • 25
181
votes
15 answers

Anatomy of a "Memory Leak"

In .NET perspective: What is a memory leak? How can you determine whether your application leaks? What are the effects? How can you prevent a memory leak? If your application has memory leak, does it go away when the process exits or is killed? Or…
huseyint
  • 14,953
  • 15
  • 56
  • 78
100
votes
6 answers

Type exists in 2 assemblies

I have created two .NET Interop assemblies from two different third-party COM DLLs. Both of the COM DLLs contained a type named COMMONTYPE. Therefore, COMMONTYPE is now exposed through the two Interop assemblies as well. I have a third project that…
Kou S Hal
  • 1,001
  • 2
  • 7
  • 4
83
votes
3 answers

Turn a simple C# DLL into a COM interop component

How do I make a C# DLL into a COM interop DLL that can be consumed by a VB6 application?
Elena Lawrence
  • 993
  • 1
  • 7
  • 6
78
votes
2 answers

"Register for COM Interop" vs "Make assembly COM visible"

What is the real difference between these two options? What I know is: Register for COM Interop This options executes regasm on the assembly and registers the assembly as an COM component(or maybe not) in the registry with all COM like registry…
A9S6
  • 6,575
  • 10
  • 50
  • 82
68
votes
1 answer

What does "Register for COM Interop" actually do?

What exactly does the VS project option "Register for COM interop" actually do? Because when I build my library with this option enabled I can call CreateObject on my library from VBScript. But if I build without this and then run regasm manually…
hackerhasid
  • 11,699
  • 10
  • 42
  • 60
62
votes
10 answers

Starting and stopping IIS Express programmatically

I am trying to build a small application in C# which should start/stop an IIS Express worker process. For this purpose I want to use the official "IIS Express API" which is documented on MSDN: http://msdn.microsoft.com/en-us/library/gg418415.aspx As…
Mike
  • 1,992
  • 4
  • 31
  • 42
46
votes
2 answers

Clean up Excel Interop Objects with IDisposable

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…
ruedi
  • 5,365
  • 15
  • 52
  • 88
44
votes
9 answers

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

I am attempting to capture some data from Excel from within a 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…
Aykut Saribiyik
  • 775
  • 1
  • 6
  • 15
33
votes
4 answers

How to get type of COM object

I am referencing a COM library in Visual Studio, so it has automatically created the corresponding Interop assembly for me. I would like to do a GetType() on these com objects, but they always return System.__ComObject. Querying them for an…
user65199
32
votes
6 answers

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

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…
jw_pr
  • 323
  • 1
  • 4
  • 5
20
votes
10 answers

Is it possible to intercept (or be aware of) COM Reference counting on CLR objects exposed to COM

I have rephrased this question. When .net objects are exposed to COM Clients through COM iterop, a CCW (COM Callable Wrapper) is created, this sits between the COM Client and the Managed .net object. In the COM world, objects keep a count of the…
Binary Worrier
  • 50,774
  • 20
  • 136
  • 184
20
votes
5 answers

COM Interop without regasm

I'm a limited user, and I need to write an Outlook macro that exposes a C# library in Outlook 2003 and 2007. I do not have any admin privilges at all, not even at install time, so I can't run RegAsm and I can't (I assume) write a managed…
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
20
votes
1 answer

Return array of interface from a .NET method via COM4J

How can I return an array of objects (implementing a COM interface) from a C# method to a Java method via COM4J? Example C# class that generates an array: using System; using System.Runtime.InteropServices; namespace Example { …
finnw
  • 47,861
  • 24
  • 143
  • 221
1
2 3
99 100