interop

How to unregister my .net assembly when it's no longer in the same location?

I have a dll that's registered for com interop, so under HKLM\Software\Classes\CLSID[my guid]\InprocServer32[my version no]\Codebase it has the path of the registered dll. However, I've rearranged my folder structure so that path is no longer correct. Is there a way of unregistering that dll without putting it back, then unregistering, t...

.NET 1.1 and .NET 2 config files working together

I have inherited a rather large project consisting of an application written in VB6 and several DLL's and ActiveX controls written in VB6, VB.NET 1.1 and VB.NET 2. I want to change one of the settings for one of the DLL's written in VB.NET 2 that is in its application.dll.config file, but it seems to be having no effect. My main VB6 app...

C# 2.0 Fastest way to parse Excel spreadsheet

What is the fastest way to read large sets of data from excel from Csharp. Example code would be great . . ...

InsertStyleSeparator in Word for Range objects (not Selection objects)

We're currently doing some Word automation, and want to be able to insert a Style Separator into a Range object. We've found how to do it with the Selection object (InsertStyleSeparator) but can't seem to figure out how to do that with Range objects. Does anyone know how to make that work? Relevant links I've found so far: Style Separ...

Workaround to see if Excel is in cell-edit mode in .NET

I have an application written in VB.NET that interacts with Excel via interop. I eventually ran into the known issue of Cell-edit mode (see MSDN and stackoverflow for some background). I have been trying to convert the suggested code to VB.NET but keep getting the following error: Reference required to assembly 'office, Version=11.0....

Trouble with Web Service using COM object

I have a VB.NET web service that is calling a Interop COM object. When I make multiple calls to the web service at the same time, the web service processes fine until it gets to calling the first method of the COM object. At this point, it seems as though the calls to the COM object get put on a stack and they get processed on a FIFO b...

How to convert IPictureDisp to System.Drawing.Image

From a COM library (Microsoft Office Document Imaging aka MODI) I receive an image as an IPictureDisp which I would like to convert to a System.Drawing.Image object. What would be the best way to do that? Currently I'm using the code below, which however throws an NotImplementedException. internal sealed class IPictureDispHost : AxHo...

.NET2.0 C# Interop: How to call COM code from C#?

In my last development environment, I was able to easily interact with COM, calling methods on COM objects. Here is the original code, translated into C# style code (to mask the original language): public static void SpawnIEWithSource(String szSourceHTML) { OleVariant ie; //IWebBrowser2 OleVariant ie = new InternetExplorer(); ...

Jython and python modules

I've just started using the PythonInterpreter from within my Java classes, and it works great! However, if I try to include python modules (re, HTMLParser, etc.), I'm receiving the following exception (for re): Exception in thread "main" Traceback (innermost last): File "", line 1, in ? ImportError: no module named re How could I m...

Intercepting hyperlinks in an embedded Word document

Hello, I'm working on an app which uses embedded Word documents. We have a feature which allows them to insert a small clickable image into the doc - when the user clicks on it, we want the app to open another window based on some data specified by the user when the image was added. What the application does now is: When the image is ...

GetSystemMetrics returning incorrect results

I'm calling the GetSystemMetrics API call from C# using the following DllImport signature: [DllImport("user32.dll", SetLastError = true)] internal static extern int GetSystemMetrics(SystemMetric smIndex); The SystemMetric enum is (for the most part) taken from pinvoke.net. For my needs, I am calling GetSystemMetrics twice, on...

Is there a way to call an unmanaged (not COM) dll from C# application?

Hello, Is there a way to use (reference) a DLL written in an unmanaged C++ (not a COM library) in my C# application? When I try to reference it from within Visual Studio, I get 'not a COM object' error message. Maybe there is some kind of translator\router that would COMify my DLL reference? I have no clue how COM and COM interop work...

Call F# code from C#

I am playing around with F# and C#, and would like to call F# code from C#. I managed to get it to work the other way around in Visual Studio by having two projects in the same solution, and adding a reference of the C# code to the F# project. After doing this, I could call C# code and even step through it while debugging. What I am...

WPF equivalent of Application.AddMessageFilter (Windows Forms)

Hello. I was using Application.AddMessageFilter() in my WinForms applications (when working with unmanaged code). Now I'm switching to WPF and can't find this functionality. Please advice where it can be found or implemented. Thank you. ...

Discrimanant taskkill.exe for excel.exe

I have to run Excel on a server and to kill the excel.exe process I am using taskkill.exe: System.Diagnostics.Process.Start("taskkill.exe", "-im excel.exe /f"); My only problem is that if there is someone who is also using the server who is working on excel (It could happen) then their processes will be killed also. Is there anyway ar...

Portable / Interoperable WCF Contracts

I was wondering if anybody out there had some good tips/dos and don'ts for designing WCF contracts with a mind for web-service interoperability, both in terms of older Microsoft web service technologies (e.g. WSE) and non-Microsoft technologies such as Java calling WCF web services. For example: are there any special rules that need t...

Tricky integration of a legacy PHP app and a new Ruby on Rails app

We have an old legacy PHP application. Now I want to write a new application module using Ruby on Rails. Deployment is a one problem. I guess that it should be possible to run PHP app (via mod_php) and RoR app (via mod_proxy / mongrel) on a one Apache server. I don't want to use mod_rails because it requires to run php via fcgi. So is ...

.NET mshtml: How to pass a BSTR SAFEARRAY?

The class mshtml.HTMLDocumentClass in Microsoft.mshtml.dll assembly has a method: public virtual void write(params object[] psarray); Avoiding the real question for a moment, what code would you use to call write()? Would you use: String html = "<html><body>Hello, world!</body></html>"; mshtml.HTMLDocumentClass doc; ... doc.write(htm...

Controlling Office 2007 with .NET: which direction?

I want to retrieve items from Fortress via its .NET API and load their descriptions into Project 2007. I was thinking about the 'best' way to do this, so I thought I would put it to my fellow stackers: Should I write a .NET assembly and wrap it in COM for Project 2007 to call from VBA? Or should I write a .NET assembly that calls Proje...

Do I need to delete structures marshaled via Marshal.PtrToStructure in unmanaged code?

I have this C++ code: extern "C" __declspec(dllexport) VOID AllocateFoo(MY_DATA_STRUCTURE** foo) { *foo = new MY_DATA_STRUCTURE; //do stuff to foo } Then in C# I call the function thus: [DllImport("MyDll.dll")] static extern void AllocateFoo(out IntPtr pMyDataStruct); ... MyDataStructure GetMyDataStructure() { IntPtr p...