interop

What is the proper way to manage large IStreams?

I am writing a C# class library to transfer large volumes of data through COM automation using an IStream. It uses the CreateStreamOnHGlobal API call to create the stream, and the methods within System.Runtime.InteropServices.COMTypes.IStream to work with it. My question is, when transferring large volumes of data, what is the best way...

Use Visual Studio Setup Project to automatically register and GAC a COM Interop DLL

I've created a .NET assembly for COM interop and it is working well on my development machine. I'm currently trying to figure out how to deploy the DLL to a target machine using Visual Studio's "Setup Project." How can I use the VIsual Studio setup project to do the following things: Register the assembly (currently using regasm). T...

How to declare scala method so that it can be called from Java using varargs style

I have 2 simple methods in a scala library class: class Foo { def bar(args : String*) : Unit = println("Foo.bar with: " + args) def bar(args : Array[String]) : Unit = bar(args.toSeq : _*) } This all compiles nicely. I then put this in a library foo.jar and try and compile the following piece of Java: import Foo public class Test ...

Pass multidimensional (safe)array from C# to COM

I have a COM object that takes a 0 bounded safearray of two dimensions. I need to pass this array into my C++ COM object. I can pass the VB6 multidim arrays into the C++ side without a problem, but I have no idea how to set this up in C# so that it will be marshalled correctly. Does anyone know the steps to set up a mulitidimensional arr...

Excel Interop Manipulate ScrollBar on Worksheet

I'm opening an excel worksheet using the Microsoft.Office.Interop.Excel COM interface. I'm trying to adjust the "maximum" value of a scroll bar embedded into a worksheet. I can find the scroll bar with the following: app = new Excel.Application(); wb = app.Workbooks.Open( Path.GetDirectoryName(Application.ExecutablePath)+@"\template...

What good .NET/COM book are out there?

I've been working as .NET developer for a few years now and have no other windows development experience worth noting. Now I'm in a position where I have to use and maintain .NET code that uses older VB6 code. Other people are maintaining and replacing this code but for the next couple years I'll have to live with it. As far as I can t...

C# .net Excel Interop leaves Excel process hanging

We use Excel interop in numerous places in our code, however I have one function which doesn't ever seem to close down the Excel process it uses.. I've simplified the code down, and it just seems like whenever I open a workbook in this function it stays hanging around. I've included the code below, I've made sure every object is defined,...

Accessing unregistered COM objects from pythonvia a registered TLB

I have three pieces of code that i'm working with at the moment: A closed source application (Main.exe) A closed source VB COM object implemented as a dll (comobj.dll) Code that I am developing in Python comobj.dll hosts a COM object (lets say, 'MainInteract') that I would like to use from Python. I can already use this object perfec...

Will using factory methods in .NET COM Interop increase performance?

I'm working on a VB6 application that consumes .NET objects via COM Interop. The application is working well, but I feel like I'm taking a performance hit each time I instantiate a .NET object from within VB6. For example, I have VB6 code that loops through a recordset and instantiates new .NET objects for each item in the recordset an...

Calling COM visible managed component from managed code through COM wrapper

Hi, I have a 3rd party component, lets say FIPreviewHandler to handle preview, which implements IPreviewHandler. FIPreviewHandler is implemented as a Managed Component, and uses the IPreviewHandler interface and related interfaces through means of an interop. FIPreviewHandler is registered using regasm.exe as COM. I have a client appli...

Changing a window's restore position using SetWindowPlacement doesn't work on every window

I'm using the SetWindowPlacement function to (1) maximize and (2) change the restore position of external windows on the desktop. But when I use this command on WinForm windows, it doesn't seem to set the restore location correctly. (The WinForm window I'm testing with is just a VS2008 WinForms application run without modification.) So, ...

tlbexp.exe changes method names' case

I have a rather strange problem. I am exporting an interface from a C# library to COM. I have enabled the 'register with COM' project setting, so it calls tlbexp.exe to make the type libs. We use camel case on our method names and I noticed that the exported type library changes these any method that happens to coincide with a class nam...

how to set the active sheet using Excel PIA

Hi, I'm using multiple sheets within my Excel application and want to activate (set focus on) a particular sheet upon exit.. Basically I want to set ActiveSheet property on my workbook, but since the property is readonly, is there any other way to achieve this? Thanks, Sam ...

Strange consequences of "ref" keyword in C# to COM interop

Consider an excerpt from code that can be found here: namespace WinSearchFile { public class Parser { [DllImport("query.dll", CharSet = CharSet.Unicode)] private extern static int LoadIFilter (string pwcsPath, ref IUnknown pUnkOuter, ref IFilter ppIUnk); [ComImport, Guid("00000000-0000-0000-C000-000000...

Windows 7, VS2010, .NET and AxMSCommLib

I have a project that is referencing the AxMSCommLib in VS2010 C#.. My Windows 7 Dev machine doesn't have or can't find this reference. Does anyone have any info on where to get this reference to make it work? ...

AxMSMAPI Windows 7 C# .NET Interop Missing

I have a project that is referencing the AxMSMAPI in VS2010 C#.. My Windows 7 Dev machine doesn't have or can't find this reference. Does anyone have any info on where to get this reference to make it work? ...

how to use C dll headers library in c#

Hello ; I am very new to C#, and i am trying to use a help package for my project. The package is written in c and has 1) /bin/ several .dll files 2) /include/ has a header file 3) /lib/msvc/ .lib file my question is how can i use those files in my C# WPF project? i know there is no "#include" in C#, and the .dll can not be imported ...

Changing web.config unloads ASP.NET application, but doesn't unload "enough"

We have an ASP.NET web application, which is a C# DLL, that references a C++/CLI DLL, that links against some native static libs. When we edit the web.config file, the appdomain unloads itself as expected, however at the next web request the application crashes with some access violation exception from our native code. Further investi...

Probing .NET Assembly with Registration Free COM/.NET Interop

We have one assembly that is used by the VB6 executable via COM Interop. This assembly uses other .NET assembly (not available for COM). We have defined a .manifest for our VB6 application, so that we can use the .NET assembly without registration. We also defined a .config for our VB6 application, with probing settings, to look in subdi...

C++ and C# interoperability : P/Invoke vs C++/CLI

In the course of finding a way to interoperate between C# and C++ I found this article that explains about P/Invoke. And I read a lot of articles claiming that C++/CLI is not exact C++ and requires some effort to modify from original C++ code. I want to ask what would be the optimal way when I have some C++ objects (code/data) that I ...