com-interop

Anatomy of a "Memory Leak"

In .NET perspective: What is a Memory Leak? How to understand whether your application leaks? What are the effects? How to prevent a memory leak? If your application has memory leak, does it go away when the process exits or killed? Or do memory leaks in your application affects other processes on the system even after process completi...

How can I use classes from VisualBasic-Express in VBA for Excel or Access projects?

I saved my VB-Express code as .dll and registered it with regasm and made a .tlb file. But when I try to run a function from it in an Excel-modul I get: Run-time error ‘453’: Can’t find DLL entry point RegisterServiceProcess in kernel32 What step did I miss? ...

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...

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...

How to properly clean up Excel interop objects in C#

I'm using the Excel interop in C# (ApplicationClass) and have placed the following code in my finally clause: while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { } excelSheet = null; GC.Collect(); GC.WaitForPendingFinalizers(); Although, this kind of works the Excel.exe process is still in the background...

How do I access IMetaDataEmit and other MetaData COM interfaces from C# or F#?

I am writing a compiler in F# and I want to be able to access the unmanaged metadata COM interfaces in the .net runtime. Before anybody mentions it, Reflection.Emit is not suitable for my purposes, nor do I want to use any other method than the metadata COM interfaces. I've imported mscoree.tlb but it doesn't seem to include the interfa...

How to obtain a list of available COM interfaces in Windows

Is there any way of obtaining a list of registered COM interfaces on a windows machine, with GUIDs? Before anybody thinks this isn't related to programming, I need this data in order to reference a COM interface in F# (or C#) for interfaces that tlbimp isn't exposing. ...

How to tell if Excel Application is in cell-edit mode?

I'm writing an Excel Addin using COM Interop from .net. I have a command that pops up a dialog, and from the dialog I do some work like collecting data from the used range of several sheets. The problem is that if a cell is in edit mode, some of the calls that I need to make will throw exceptions. I would like a way of determining before...

.NET COM Interop Method Signature

What interop signature would you use for the following COM method? I am interested particularly in the final two parameters, and whether to try to use MarshalAs with a SizeParamIndex or not. HRESULT GetOutputSetting( DWORD dwOutputNum, LPCWSTR pszName, WMT_ATTR_DATATYPE* pType, BYTE* pValue, WORD* pcbLength ); Doc...

Does COM interop respect .NET AppDomain boundaries for assembly loading?

Here's the core problem: I have a .NET application that is using COM interop in a separate AppDomain. The COM stuff seems to be loading assemblies back into the default domain, rather than the AppDomain from which the COM stuff is being called. What I want to know is: is this expected behaviour, or am I doing something wrong to cause th...

.NET Interop: Using an assembly in the current directory

I'm trying to use a .NET assembly from VB6 via interop without placing it in the GAC and without using the /codebase argument for regasm.exe. From what I understand, when I run regasm.exe on a .NET class library, it creates a registry entry for each class in the class library telling the COM clients they should load mscoree.dll that ser...

Load COM oject from jsp

Hi, I am developing a jsp application. I am forced to load a COM object. Can such a thing can be done? if yes, how?? Many thanks, Ofer ...

COMException: The data area passed to a system call is too small

The message defined in the title of this post, along with the HResult 0x8007007A occasionally occurs while creating an instance of a Windows Workflow Foundation Runtime. The error text is pretty self explanitory, and using Reflector over the Workflow Foundation assemblies I have narrowed down the problem to one of the following calls in...

Handling custom .Net exceptions in COM+ (VB)?

Hi, I'm about to start writing a .Net component which will be called from a VB COM+ service (the new component is a DLL which calls out to a webservice and returns based on the response). I'm not sure how to handle error conditions that might occur in the .Net code in the calling VB. The two types of errors I'm worried about are: exc...

Lots of build warnings when COM objects ActiveDs or MSXML2 are referenced

After moving a project from .NET 1.1 to .NET 2.0, MsBuild emits lots of warnings for some COM objects. Sample code for test (actual code doesn't matter, just used to create the warnings): using System; using System.DirectoryServices; using ActiveDs; namespace Test { public class Class1 { public static void Main(string[]...

What are alternatives to generic collections for COM Interop?

I am attempting to return a collection of departments from a .NET assembly to be consumed by ASP via COM Interop. Using .NET I would just return a generic collection, e.g. List<Department>, but it seems that generics don't work well with COM Interop. So, what are my options? I would like to both iterate over the list and be able to acce...

.Net - interop assemblies taking 15 seconds to load when being referenced in a function

This is a C# console application. I have a function that does something like this: static void foo() { Application powerpointApp; Presentation presentation = null; powerpointApp = new Microsoft.Office.Interop.PowerPoint.ApplicationClass(); } That's all it does. When it is called there is a fifteen second delay be...

Milliseconds missing when getting a DateTime value from Excel using .Net Interop

If I put a DateTime value into an Excel cell using Range.set_value through .Net COM Interop, and then retrieve the value of that same cell using Range.get_value, the Millisecond part of the value is not returned, though everything else is correct. Is this a bug? What is the workaround? I'm guessing that using the Value2 property instea...

Exposing the indexer / default property via COM Interop

I am attempting to write a component in C# to be consumed by classic ASP that allows me to access the indexer of the component (aka default property). For example: C# component: public class MyCollection { public string this[string key] { get { /* return the value associated with key */ } } public void Add(string k...