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:

1756 questions
767
votes
42 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
  • 15,789
  • 18
  • 54
  • 74
291
votes
17 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,501
  • 5
  • 22
  • 25
173
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,450
  • 15
  • 52
  • 77
81
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
  • 811
  • 1
  • 6
  • 4
75
votes
4 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
  • 913
  • 1
  • 7
  • 6
73
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,125
  • 10
  • 48
  • 81
64
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,151
  • 9
  • 40
  • 60
60
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,916
  • 4
  • 28
  • 39
37
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
  • 4,417
  • 11
  • 41
  • 73
31
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
  • 313
  • 1
  • 4
  • 5
30
votes
12 answers

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

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…
Aykut Saribiyik
  • 630
  • 1
  • 6
  • 14
29
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
19
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
  • 800,742
  • 167
  • 1,811
  • 1,896
19
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
  • 45,253
  • 22
  • 134
  • 212
18
votes
1 answer

When is it necessary/appropriate to use InAttribute and OutAttribute for COM Interop

I am trying to go through the mess of COM interop definitions we have scattered across various projects and collect them into a single, known-good location from which the whole dev team can benefit. Part of this effort involves cleaning up the…
Michael Edenfield
  • 27,188
  • 4
  • 77
  • 114
1
2 3
99 100