interop

Handling events exposed on a .NET class via COM in VB6

Handling events exposed on a .NET class via COM in VB6 My test .NET (class libary registered for interop in compiler settings) code: Imports System.Runtime.InteropServices <InterfaceType(ComInterfaceType.InterfaceIsIDispatch), ComVisible(True)> _ Public Interface MyEventInterface <DispId(1)> Event Exploded(ByVal Text As String) ...

What's the right way to communicate between 2 or more .Net applications running on a same computer without using web services?

If my applications run on a same computer or even on different computers in a same LAN and need intense and quick communication, it seems illogical for me to use text-encoded web services and HTTP. I could possibly use IP/TCP/UDP sockets and invent my own protocols, but believe there is a standard way for .Net applications to send/receiv...

Visual Studio project remains "stuck" when stopped

Hi, Currently developing a connector DLL to HP's Quality Center. I'm using their (insert expelative) COM API to connect to the server. An Interop wrapper gets created automatically by VStudio. My solution has 2 projects: the DLL and a tester application - essentially a form with buttons that call functions in the DLL. Everything works...

Using Wrapper objects to Properly clean up excel interop objects

All of these questions: Excel 2007 Hangs When Closing via .NET How to properly clean up Excel interop objects in C# How to properly clean up interop objects in C# struggle with the problem that C# does not release the Excel COM objects properly after using them. There are mainly two directions of working around this issue: Kill the...

Excel automation: Close event missing

Another hi all, I am doing Excel automation via Interop in C#, and I want to be informed when a workbook is closed. However, there is no Close event on the workbook nor a Quit event on the application. Has anybody done that before? How can I write a piece of code which reacts to the workbook being closed (which is only executed if the ...

Programming the Virtual Disk Service API in C# using COM Interop

I would like to write a small utility/class library in C# that can enumerate the primary partitions on the disk associated with volume C on Windows 7. I would like to modify the active flag for any one the primary partitions on that disk. I would like to "consume" this library from managed code (C#). As I understand it, I will need to us...

How can I influence the Interop.Excel Application.UsableWidth?

I'm generating an Excel document server-side using .NET Interop.Excel and Office 2007. One problem (so far) is that FreezePanes does not work consistently. For some users, Excel automatically hides the first few columns if it thinks the freeze point may not be visible. I've captured several variables trying to debug this, and the criti...

Design interoperable web services

Hi everyone, I'm designing a set of web services to allow our clients to connect from their apps to one of our systems. Our clients have their apps developed in all varieties of frameworks (.NET, Java, PHP, Python and even the occasional all JS app), so obviously WS is the way to go. Investigating a little about truly interop WS I've f...

Releasing Excel after using Interop

Hi everyone I've read many post looking for my answer, but all are similar to this: http://stackoverflow.com/questions/1610743/reading-excel-files-in-vb-net-leaves-excel-process-hanging My problem is that I don't quit the app... The idea is this: If a User has Excel Open, if he has the file I'm interested in open... get that Excel in...

Is there a programmatic way to determine whether the file is being used?

Case and point: I need to open an Excel file via Interop and it would help a lot to avoid ugly COM errors if I knew that the file was in use. Other than trying to open the file and catching the exception, is there a programmatic way to determine whether the file is in use? ...

converting between struct and byte array

his question is about converting between a struct and a byte array. Many solutions are based around GCHandle.Alloc() and Marshal.StructureToPtr(). The problem is these calls generate garbage. For example, under Windows CE 6 R3 about 400 bytes of garbarge is made with a small structure. If the code below could be made to work the solution...

How to get the reference of latest version of MS Excel in VB.net application?

I am using Excel Interop in my VB.net application. I am using Microsoft Office 11.0 Object Library and Microsoft.Office.Interop.Excel for excel automation. Both the dlls are for Office 2003. My question is, how can I get my project to refer to the latest version of MS Office( say Office 2010) ...

How to communicate between C# and Wpf projects ?

Hey folks , i'm working with 3 projects , one C# (let's called it A ) the other two are Wpf projects(let's call them B,C). The project B has a main window which contains a button ,when i press the button it shows the project "A" main's window .(i've done that by adding the right references and doing the code below in button click ev...

Problem opening Excel workbook using Excel Interop

Hi everyone, I'm writing a C# forms application to open an existing Excel workbook using the Excel Interop. Everything works fine. I can read and write fine. I do not save the workbook until the user close the C# application. The problem happens when my program is running and the user accidentally opens the same workbook with Excel. I g...

C# Excel Interop : Excel process remains in memory until parent form closed.

Hello, In my form I am doing something as simple as private void btnPrintPickList_Click(object sender, EventArgs e) { using (var salesRpt = new SalesOrder(CurrentItem())) { salesRpt.CreateSpreadSheet(); salesRpt.Dispose(); } } I have followed the "no 2 dots rule for excel interop". protected ExcelSheet(bo...

How to call functions inside a C dll which take pointers as arguments from C#

Hi people, this is my first post here! I'm trying to make a windows forms program using C# which will use a precompiled C library. It will access a smart card and provide output from it. For the library, I have a .dll, .lib and .h and no source. In the .h file there are several structs defined. Most interesting functions of the .dll exp...

Excel interop: Restore minimized window

In my winforms app interacting with Excel through the com interop, I'm trying to attach to an existing Excel process if there is one. Getting the object seems to work well, but if the Excel application is minimized (which is quite likely in my use case), I don't manage to restore the window and bring it to the front. I've tried the fol...

"No printers are installed." problem when using excel 2003 interop sheet.PageSetup through a WCF service

We have a WCF service that generates an Excel file off of a template and feeds it back to the client in a byte array. For some reason, we are getting an error when we try to do this: sheet.PageSetup.CenterHeader = sheet.PageSetup.CenterHeader.Replace("[customerName]", customerName).Replace("[dateTime]", date.ToShortDateString()); When...

Office Interop addins installer?

I have three C# Solutions in Visual Stuido 2008, one each for Word, Excel and PowerPoint using interop to hook various events. In each Solution, I have exactly one class, the one created by default when using File -> New -> Project -> Visual C# -> Office -> 2007. Now that I have my addins working properly, it's time to create an instal...

How do I set locked cell protection options in Excel with C# and Interop?

Here's the background info. I have an app that writes to an excel 2007 .xlsm file and I am using C# and the Excel 12.0 interop object libraries to do it, along with Visual Studio 2010. I am able to change the cell values and formulas, set the font and font style, set the cells to locked or not, etc. The last thing I need to do is to set ...