interop

Initializing an array on arbitrary starting index in c#

Is it possible in c# to initialize an array in, for example, subindex 1? I'm working with Office interop, and every property is an object array that starts in 1 (I assume it was originally programed in VB.NET), and you cannot modify it, you have to set the entire array for it to accept the changes. As a workaround I am cloning the orig...

ADODB interop issue

We have project PrjDb.dll in vb 6.0 that has a reference to ado 2.5. The project is built on Machine A. Now when we generate an interop for PrjDb.dll on another machine B, we end up with a new ADODB.dll with ver 2.5 in version field instead of linking it with the Primary Interop Assembly adodb.dll ( found under 'Program Files\Microsoft.N...

How to build a 64-bit .NET DLL, with 64-bit COM interop?

I need to build a managed DLL, targeted for x64, and expose it via x64 COM. I need a walk through, good article, etc... Interop is fairly straightforward, but when you talk about x64 on both sides, I can't find anything. ...

What is the most efficient way to handle the lifecycle of an object with COM interop?

I have a Windows Workflow application that uses classes I've written for COM automation. I'm opening Word and Excel from my classes using COM. I'm currently implementing IDisposable in my COM helper and using Marshal.ReleaseComObject(). However, if my Workflow fails, the Dispose() method isn't being called and the Word or Excel handles ...

Is it possible to get Code Coverage Analysis on an Interop Assembly?

I've asked this question over on the MSDN forums also and haven't found a resolution: http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3686852&SiteID=1 The basic problem here as I see it is that an interop assembly doesn't actually contain any IL that can be instrumented (except for maybe a few delegates). So, although I can p...

Excel Addin Access Violation

Using c#, VS2005, and .NET 2.0. (XP 32 bit) This is a Winforms app that gets called by a VBA addin (.xla) via Interop libraries. This app has been around for a while and works fine when the assembly is compiled and executed anywhere other than my dev machine. On dev it crashes hard (in debugger and just running the object) with "Unhandl...

What's the best freely available C# wrapper for BITS?

BITS, the Windows background intelligent transfer service. Looks like there are a few C# wrappers around that manage the interop to BITS, does anybody have any opinions on the best one? ...

Is there a .NET performance counter to show the rate of p/invoke calls being made?

Is there a .NET performance counter to show the rate of p/invoke calls made? I've just noticed that the application I'm debugging was making a call into native code from managed land within a tight loop. The intended implementation was for a p/invoke call to be made once and then cached. I'm wondering if I could have noticed this mist...

How to stream binary data to standard output in .NET?

I'm trying to stream binary data to the standard output in .NET. However you can only write char using the Console class. I want to use it with redirection. Is there a way to do this? ...

How to use .NET 3.0 with Visual Studio 2005?

My Google-fu is failing me on this question. I have a coworker who has Visual Studio 2005 on his machine. I have Visual Studio 2008. He wants to open a project I wrote in C# 3.0, and we've gotten that far, but VS2005 barfs on the 3.0 code, like var. He has the 3.0 and 3.5 frameworks installed, as well as the Visual Studio 2005 Extensio...

How can a modeless VB6 application do cleanup when the application is shutting down?

A VB6 application is using the Interop Forms Toolkit to work with forms written in .NET. The documentation for the toolkit advises calling a method on the toolkit to advise the toolkit when the VB6 application is shutting down. The VB6 application uses a Sub Main procedure that loads a splash screen, then displays several modeless forms...

Dump CCWs and RCWs in a mixed managed/unmanaged process

I have a mixed managed/unmanaged environment (Visual Studio and ReSharper) and I suspect CCW or RCW leak. Is there any way to dump all currently allocated wrappers and identify their source/target? I have WinDbg, SOS & SOSEx, so I can see total number of RCWs and CCWs with !syncblk command. I just want to see objects, so I can call !gcro...

Registering a custom win32 window class from c#

I have a new application written in WPF that needs to support an old API that allows it to receive a message that has been posted to a hidden window. Typically another application uses FindWindow to identify the hidden window using the name of its custom window class. 1) I assume to implement a custom window class I need to use old sch...

Workaround for J2ME Hessian limitations ?

The official J2ME implementation of Hessian seems to have serious limitations : complex objects are not supported. This limitation is not mentioned anywhere on the online documentation, but if you google "hessian j2me" you will find posts about this problem. No solutions found with google though. Does anyone have a solution for this pro...

Lisp+PHP ?

At the moment I use PHP for almost everything I develop for the Web but its linguistic limitations are starting to annoy me. However, as I developed some practices and maintain some PHP libraries that help me a lot, I don't feel I'd be ready to just switch to LISP throwing away all my PHP output. It could even be impossible on the server...

Using P/Invoke correctly

Hi, I need to call an external dll from c#. This is the header definition: enum WatchMode { WATCH_MODE_SYSTEM = 0, WATCH_MODE_APPLICATION = 1 }; LONG ADS_API WDT_GetMode ( LONG i_hHandle, WatchMode * o_pWatchMode ); I've added the enum and the call in C#: public enum WatchMode { WATCH_MODE_SYSTEM = 0, WAT...

Retrieving the original error number from a COM method called via reflection

I have a VB6 COM component which I need to call from my .Net method. I use reflection to create an instance of the COM object and activate it in the following manner: f_oType = Type.GetTypeFromProgID(MyProgId); f_oInstance = Activator.CreateInstance(f_oType); I need to use GetTypeFromProgID rather than using tlbimp to create a library...

How do I create a Microsft Jet (Access) database without an interop assembly?

I need to create an access (mdb) database without using the ADOX interop assembly. How can this be done? ...

MainSoft Grasshopper, .Net to Java

I just stumbled upon MainSoft's Grasshopper, which claims to cross-compile .Net ILM to Java bytecode. It seems to use the Mono implementation of the .Net libraries. All of the samples refer to web apps, but my requirement would be to cross-compile a .Net API (class library) to a Java API so that Java clients can use the API. Does anyone ...

Marshal C++ "string" class in C# P/Invoke

I have a function in a native DLL defined as follows: #include <string> void SetPath(string path); I tried to put this in Microsoft's P/Invoke Interop Assistant, but it chokes on the "string" class (which I think is from MFC?). I have tried marshaling it as a variety of different types (C# String, char[], byte[]) but every time I eit...