interop

How to use Office from Visual Studio C#?

The technique for adding a reference to the COM interop of Office in Visual Studio is to go to: References Add Reference Select the COM tab Select Microsoft Office 11.0 Object Library And magically named reference appears: Microsoft.Office.Core The Project.csproj file shows the details of the reference: <COMReference Include="Mic...

C# Visual Studio: How to have mulitple developers on a solution that references Office?

When i add a reference to Office COM Library, i to go: References Add Reference Select the COM tab Select Microsoft Office 12.0 Object Library And magically named reference appears: Microsoft.Office.Core The Project.csproj file shows the details of the reference: <COMReference Include="Microsoft.Office.Core"> <Guid>{2DF8D04...

MX Record Query fails

print("code sample");I'm a managed codeprint("code sample"); guy, so when I interop with unmanaged code, and it doesn't work as advertised, I get twitchy. Can someone explain to me why this would come back with no MX records, when a command line nslookup works? [DllImport("dnsapi", EntryPoint = "DnsQuery_W", CharSet = CharSet.Unicode, S...

Exposing events from .NET to COM

Hello everyone, recently I have been encountering problems with exposing events from .NET to COM. I have been successful with this example (conceptually taken from http://blogs.msdn.com/andreww/archive/2008/10/13/exposing-events-from-managed-add-in-objects.aspx): // The delegate type for our custom event. [ComVisible(false)] public de...

Using ActiveX PropertyBags from C#

I have created a .NET user control with an ActiveX interface. It works well. Now, I want to be able to read and write from the property bag for the ActiveX interface. How would I do this? ...

Winforms WPF interop performance

My project requires a background thread to initiate the creation of a WPF control hosted in a Winform. The creation of said control must be performed on the foreground thread, which is very costly and causes the UI to hang for 1 to 2.5 seconds (depending on whether this is the first time the control is created). Are there any pre creat...

Execute VBA Macro via C# Interop?

Hi all, just wondering if anyone could suggest why I might be getting an error? I'm currently trying to execute a macro in a workbook by calling the Application.Run method that the interop exposes. It's currently throwing the following COM Exception: {System.Runtime.InteropServices.COMException (0x800A03EC): Cannot run the macro Macro1...

Interoperating between Matlab and C#

After peeking around the internet it looks like it is possible to interop between C# and Matlab. I am wondering if anyone has had success with it and what they did to do so. If possible somehow pulling it off without the use of COM. Thanks for your time. ...

Using updated ActiveX component in an existing WinForms application ?

Currently there is a Winforms application that is using an ActiveX component .ocx through the two interops. Now that there is a new version of the ocx available, I would like force the WinForms app to use newer version. Unregistering the old ocx and registering the new ocx doesn't help. Appreciate any help in achieving the same. ...

COM object in C# VS2008: Error loading type library/DLL

I am trying to reference a third party COM DLL from a Visual Studio 2008 project (.NET 3.5 SP1) on Vista Ultimate. I ran the setup for the COM component, and then discovered that it was not the right setup. So I uninstalled and ran the correct install. After adding the reference to a new C# project, not all the object methods are availa...

Use C++ class from C#

Alright so I have this C++ image capturing class. I was wondering if I could get some help..I know basic C++ (I have done one intro to c and one intro to c++ class) and I have NO idea how to do this: I need to use this class (ie create a new c++ project in my solution) and use c# to reference it and use it to save a screenshot of the s...

Word dialog shown programmatically doesn't respond to mouse clicks

The following piece of code shows an Insert table dialog: Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable]; int result = d.Show(ref missing); if (result == -1) // if user pressed OK { d.Execute(); } The problem is that the dialog does not respond to mouse clicks. It responds to keyboard input, though. Moreover, i...

How to pass a (byte[] lpData) with integer value to RegSetValueExW P/Invoke

I have this P/Invoke RegSetValueExW that sets the value to the registry key. in C# [DllImport("coredll.dll", EntryPoint = "RegSetValueExW")] public static extern int RegSetValueExW(uint hKey, string lpValueName, uint lpReserved, uint lpType, byte[] lpData, uint lpcbData); I'm having a pr...

.Net CCW no events with registration-free COM!

I have a COM Callable Wrapper that I'm using from a VB6 program, but the program won't receive COM events unless the CCW is registered. Otherwise, the CCW works fine, just no events until I remove the program's manifest file and register the CCW using "regasm /tlb /codebase theccw.dll". This is in WinXP SP3. What could be the problem? ...

Creating Win32 events from c#

I'd like create a kernel(aka named events) from C#. Do I have to interop services and wrap the native CreateEvent function or is there already a .NET class that does the job? The function that I need to run should be something like this: hEvent = CreateEvent ( NULL , false , false , "MyCSHARPEvent" ); This should notify all procs t...

Interop issue in .NET

I have a 32 bit managed assembly that access a 32 bit COM component. When i compile the assembly using the 64 bit flag, i get an error when i try to access the 32 bit COM component from it. Is there a way around this problem? ...

How to programmatically set every other column in a worksheet in Interop

Using Excel Interop (.NET) how can we set programmatically two different Excel formulas for every other column. For instance, Range r = _sheet.get_Range(_sheet.Cells[1, 1], _sheet.Cells[I, J]) r.Formula = "=something1" will do it for every cell. But within J columns every other column has to have formula "=something2". The size ...

How to inject text to the cursor focus

I am developing a .NET windows app that needs to insert text in the place where the cursor is. The cursor will be in a different application that I have no control over. I think the operating system needs to be used here to achieve this. Can you help please? ...

Can you install Office 2007 PIA's without office

First of all, my question is not quite the same as http://stackoverflow.com/questions/370407/is-office-2007-pia-deployment-possible-without-office-2007 I am not looking to use the PIA's yet. The IT engineers would ideally like to deploy the 2007 PIA's to everyone's computers before they upgrade Office 2007. This way there is fewer thi...

Registering Office 2007 PIA

I have installed the 2007 PIA and repaired my Office 2007 installation. Still, when I add a reference to the Office 12 Object Library in VS2005, I only see Office.Core and cannot add an 'imports' statement for Office.Interop I have checked that Windows\assembly\gac\ has got the interop dlls. ...