interop

Automating Excel using ASP.NET

Background We are developing some in-house utilities using ASP.NET 2.0. One of which is extracting some information from databases and building an Excel workbook containing a number of spreadsheets with data based on queries into the database. Problem The proof-of-concept prototype (a simple ASP.NET page that queries a single item fro...

ListView Empty Markup Text

Vista has introduced a new API to display a text in the list view control when it doesn't have any items. As the MSDN library states, I should process the LVN_GETEMPTYMARKUP notification. In the inherited ListView control the WndProc method is overriden: protected override void WndProc(ref Message m) { try { if(m.Msg == 78 /* WM_...

How can I pass a reference parameter (&) (not pointer) using p/invoke in C#?

I have a C++ API prototype void Func(int& size); How can I translate it to P/Invoke in C#? From what I know, if I use public static extern Func(ref int size); , the function will receive a pointer to the int instead of the value. ...

Outlook Interop: How to iterate over all items in folder

I would like to search the bodies of all outlook items. I know how to do this for the four PIM items (Notes/Tasks/Appointments/Contacts). But the code is identical for all of them with the exception of casting the COM object to the specific item type (i.e., ContactItem, AppointmentItem, etc). Is there a parent class for these PIM items...

Wrapping Visual C++ in C#

I need to do some process injection using C++ but I would prefer to use C# for everything other than the low level stuff. I have heard about "function wrapping" and "marshaling" and have done quite a bit of google searching and have found bits of information here and there but I am still really lacking. Things I have read in order of u...

Window handle C#/.NET

When working with window handles, is it good enough to use the plain IntPtr or should I subclass SafeHandle? Are there any significant pros/cons? Thanks. ...

how do i create a strong named interop dll for shdocvw.dll

I have a Browser Helper Object project in c# that (obviously) references shdocvw.dll. I think I want to create a strongly named interop dll for shdocvw.dll. How do I do this - I've seen a bunch of suggestions out there with aximp.exe and tlimp but I'm not clear how they fit together. ...

C#, Lotus Interop: Getting Message Information

I'm using Interop.Domino.dll to retrieve E-mails from a Lotus "Database" (Term used loosely). I'm having some difficulty in retrieving certain fields and wonder how to do this properly. I've been using NotesDocument.GetFirstItem to retrieve Subject, From and Body. My issues in this regard are thus: How do I retrieve Reply-To address...

Ways to use .Net within MS Access

I'd like to include custom .Net controls and .Net forms within MS Access. It's possible but I was wondering if there was any new good articles on that subject. Over time I've found a few related to the subject the but always found the process a bit cumbersome (see references below). One of the issue is deployment: my user's machines hav...

Killing an interop Application process

I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class Form1 Dim eApp As New Excel.Application Dim w As Excel.Workbook w = eApp.Workbooks.Open( "path.xls", ReadOnly:=True) .. Processing Code .. //Attempts at killing the excel application w.Close() eApp.Work...

MC++ interop array access

Using Managed C++ (VS 2005), how would you pass a array< unsigned char > to a function as a unsigned char*? ref class Utils { public: static void A(array<unsigned char, 1> a) { //How do I call B()???? } static void B(const unsigned char* a) { //do stuff } }; ...

How to get the installation directory in C# after deploying dll's

Hi! Is there some smart way to retreive the installation path when working within a dll (C#) which will be called from an application in a different folder? I'm developing an add-in for an application. My add-in is written in C#. The application that will use is written in C and needs to compile some stuff during evaluation, so I have ...

Why is my UserProperties collection empty ?

Hi, I'm using the Outlook 2003 PIA and VS 2005 to access items in a public folder. The item.UserProperties collection always comes back empty, despite the items having several user defined fields. If I add a property in code using UserProperties.Add, it is saved correctly with the item and is then available in the UserProperties next ...

COM interop assembly loading sequence

There is very strange assembly reference problem and loading problem I experience with my Outlook addin. Here are the detail (a long story :) ): I have an old Outlook addin, written and build using .Net 1.1. The addin is loaded using an unmanaged shim in its own application domain. It works OK, with .Net 2.0, even if 1.1 is not present ...

Use custom font with a COM Object in .NET

I am trying o load a custom font in C#, so it is usable by COM libraries (like ESRI) and by GDI+. I want to load the font from disk and don't want to install the font on the system. COM font is of type stdole.IFontDisp. EDIT: using in AddFontResourceEx combination with the PrivateFontCollection solves the issue. ...

powershell outlook interop send email

I'm developing a script that involves creating an email contact, and forwarding mail to that contact. Last part of the script is to automatically send a test email to the address to make sure the forwarding works. So I use the following code: [void] [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Core") $olApp = new-object...

WindowsIdentity Token in Legacy ASP

I've created a .Net library at work that is used by all of our developers. The security part of it uses Microsoft AzMan for the security backend. In order to create a security (AzMan) ClientContext I have to pass it a token value (as a uint). This is all fine an dandy until I needed to make a COM wrapper for our common library so some of...

C# interop: excel process not exiting after adding new worksheet to existing file

I've read many of the other threads here about managing COM references while using the .Net-Excel interop to make sure the Excel process exits correctly upon exit, and so far the techniques have been working very well, but I recently came across a problem when adding new worksheets to an existing workbook file. The code below leaves a z...

C#/Winform: Enter data into HTML page, submit form

I have a Winform with a BackgroundWorker. The BackgroundWorker, among other things, has to make an HTTP call to a page, fill out some data, submit the form, and retrieve the HTML that comes back after "clicking" the submit button. I've run into a number of roadblocks while doing this: Can't POST the data because the target webserver do...

Excel Interop - Efficiency and performance

I was wondering what I could do to improve the performance of Excel automation, as it can be quite slow if you have a lot going on in the worksheet... Here's a few I found myself: ExcelApp.ScreenUpdating = false -- turn off the redrawing of the screen ExcelApp.Calculation = Excel.XlCalculation.xlCalculationManual -- turning off the ca...