Questions tagged [interop]

Interoperability is a requirement for one computer system or programming language to work with another.

Interoperability is a requirement for one computer system or programming language to work with another.

A number of computer systems, especially Microsoft's .NET Framework, reduce this term to Interop.

5732 questions
49
votes
2 answers

IntPtr, SafeHandle and HandleRef - Explained

Without pointing me to MSDN, could someone give a concise, clear explanation of the purpose of each of these and when to use them. (IntPtr, SafeHandle and HandleRef)
user62572
  • 1,388
  • 2
  • 15
  • 24
49
votes
1 answer

COM object that has been separated from its underlying RCW cannot be used

I have some COM component which I call from some c# dll. I also have a winforms app that uses that .dll. When I close the app I get this exception: COM object that has been separated from its underlying RCW cannot be used. The stack trace…
Yaron Naveh
  • 23,560
  • 32
  • 103
  • 158
48
votes
8 answers

Microsoft.Office.Interop.Excel really slow

I am exporting a 1200 X 800 matrix (indexMatrix) to a excel file using the standard Microsoft.Office.Interop.Excel. The app works, just that it is really really really slow( even for the 100 x 100 matrix) . I also export in a text file through a…
Alex
  • 10,869
  • 28
  • 93
  • 165
48
votes
9 answers

Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))

I am trying to convert a .xls file to an .xlsx file on the server-side using Microsoft.Office.Interop.Excel.Workbook class as follows: workBook.SaveAs("FILENAME_HERE", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing,…
Tamas Ionut
  • 4,240
  • 5
  • 36
  • 59
47
votes
1 answer

Is C NULL equal to C++11 nullptr

I like to use nullptr instead of NULL. Now I call a C function (from libjansson in this case). NULL in C is implementation defined. For nullptr I found that "A null pointer constant is an integral constant expression (5.19) rvalue of integer type…
user877329
  • 6,717
  • 8
  • 46
  • 88
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
43
votes
8 answers

Disposing of Microsoft.Office.Interop.Word.Application

(Somewhat of a follow on from the post (which remains unanswered): https://stackoverflow.com/q/6197829/314661) Using the following code Application app = new Application(); _Document doc = app.Documents.Open("myDocPath.docx", false, false,…
Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243
42
votes
6 answers

Handling Null Values in F#

I need to interop with some C# code with F#. Null is a possible value that it is given so I need to check if the value was null. The docs suggest using pattern matching as such: match value with | null -> ... | _ -> ... The problem I'm having is…
Jonathan Sternberg
  • 6,421
  • 7
  • 39
  • 58
42
votes
4 answers

A Simple C# DLL - how do I call it from Excel, Access, VBA, VB6?

I have a simple class library written in c#. using System; namespace TestDll { public class Test { public string HelloWorld { get { return "Hello World"; } } …
divinci
  • 22,329
  • 11
  • 45
  • 56
41
votes
6 answers

Add offset to IntPtr

I'm looking for a way to perform pointer operations in C# or .NET in particular. I want to do something very simple Having a pointer IntPtr I want to get IntPtr object which points to 2 bytes ahead. I read some post that the foolowing snippet will…
Marcin Rybacki
  • 974
  • 1
  • 9
  • 19
41
votes
4 answers

Excel Interop - Add a new worksheet after all of the others

I am trying to add a new worksheet to an Excel workbook and make this the last worksheet in the book in C# Excel Interop. It seems really simple, and I thought the below code would do it: using System.Runtime.InteropServices; using Excel =…
JMK
  • 27,273
  • 52
  • 163
  • 280
39
votes
1 answer

How do I implement Serializable in Kotlin so it also works in Java?

I have some code that I've been using for years in Java, but need it in Kotlin (its interfaces extend collections interfaces). Some classes are serializable. When I try the obvious, I get "Cannot access 'Serializable': it is internal in…
GlenPeterson
  • 4,866
  • 5
  • 41
  • 49
39
votes
5 answers

Call function from DLL?

I'm new to C# and I'm trying to learn to usage of DLLs. I'm trying to wrap my objects in a DLL, and then use it in my program. public class Foo // its in the DLL { public void Bar() { SomeMethodInMyProgram(); } } So I try to pack…
Dominik Antal
  • 3,281
  • 4
  • 34
  • 50
36
votes
4 answers

Where is the System.Windows.Forms.Integration namespace?

I can't seem to find it, trying to keyboard input in a wpf form spawned from a winforms form. Found this: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/442782b1-00a1-4e2e-9cc6-ae99b6699126/ But when I try to use it, VS2008 complains…
Davy8
  • 30,868
  • 25
  • 115
  • 173
36
votes
1 answer

Why use FinalReleaseComObject instead of ReleaseComObject?

I know the basic difference as ReleaseComObject only decreases some counter by one and FinalReleaseComObject decreases it to zero. So what I usually hear is, call FinalReleaseComObject because then you are sure that the COM object is really…
Matthijs Wessels
  • 6,530
  • 8
  • 60
  • 103