com-interop

Web application to legacy code interop

I am trying to migrate a simple WinForms app to a ASP.Net web app. WinForms app is basically only a presentation layer for a complex plain C app, and interacts with legacy code through COM interop. I have modest experience in ASP.Net, javascript, jQuery, and lots of experience in WinForms and interop, so I know the basics, I just need to...

Excel Com Interop ASP.Net Cannot write file to disk. Permissions?

I've got a pretty simple web form which lets users pick reports, one specific report they want in xls with pretty formatting instead of CSV. I've whipped up the report using COM INTEROP with excel 2007. It works on my local machine and can write the file, but on the web server it fails with this error: Microsoft Office Excel cannot op...

Register managed assemblies with COM without using the GAC

I'm wondering if it possible to register assemblies with COM without having to register it with the GAC. We need to deploy some .net libraries that are exposed to classic asp using a CCW. But deployments are a nightmare. ...

HOWTO add aggregate .NET COM Interop to an ATL EXE Server??

Hello, I would like to know how one can add a .NET C# COM object (created using the COM Interop facility of .NET) to a Visual Studio 2008 ATL EXE Server. Basically, I am trying to create an out of process Automation server to hold my C# COM object to allow it to act as a Singleton server for many clients. I think all I need to do is add...

How to set platform target for a ASP.NET "web site" project

I keep running into all sorts of nuances between the "web site project" versus "web application project" - here is the latest for me: I've inherited a Visual Studio 2005 solution with several class library projects (a DAL.dll, a Biz.dll, etc.) but this is all "fronted" by a web site project rather than a web app project. While the web ...

Side-By-Side COM Interop with C# and VBA

I'm not talking about calling a VBA COM from C#... the other way around! What I would like to do is call a C# library using VBA in MS Access without registering the DLL. I've been playing around with side-by-side interop for a while without success and it has finally occurred to me that a mdb.manifest is probably not an acceptable repla...

C++ COM C# Mixed Mode Interoperation

I'm trying to understand my options for calling a C# library implementation from unmanaged C++. My top level module is an unmanaged C++ COM/ATL dll. I would like to integrate functionality of an existing managed C# dll. I have, and can recompile the source for both libraries. I understand from reading articles like this overview on MSD...

C# Child Process from Legacy C++ App Windowing Problems...

We have a c++ legacy application and have been extending it with c# applets that are invoked using COM from the parent c++ app. They bring up windows that are not modal. Moreover, I think these .NET windows are not proper children of the c++ application, since EnumChildWindows misses them, and EnumWindows finds them. One child-like beh...

ILockBytesOnHGlobal WriteAt performance decreases over time

I've created ILockBytesOnHGlobal and I write 64k of data repeatedly. What I've noticed is that WriteAt performance decreases over the time. What could be the reason for the performance slow down? Does it have to do with stream growth? Here is what I'm doing (in C#) public override void Write(byte[] buffer, int offset, int count) ...

Why do equal strings sometimes behave differently? (VB.NET COM interface)

Example: Dim Sh32 As Object = CreateObject("Shell.Application") Dim path As String = "C:\temp\catalog.zip" Dim sf As Object = Sh32.NameSpace(path) -> does not work, sf = Nothing Dim Sh32 As Object = CreateObject("Shell.Application") Dim path As String = "C:\temp\catalog.zip" Dim sf As Object = Sh32.NameSpace(path.ToString) -> works...

Where is "Inherits <baseclass>" in an Interop UserControl?

I'm looking at the Interop UserControl mechanism that's part of the "Interop Forms Toolkit" version 2.0. (This you to build a .Net UserControl that can be published as a COM object for use on VB6 forms.) I've started a new project using the "VB6 Interop UserControl" template, and what I see is a class definition that looks like this: ...

Type Mismatch error calling C# dll from VBA using com interop

What are the limitations for parameters when calling C# methods from VBA code using COM interop? I'm finding that if I call a method that takes a single simple type (string, int, etc) it works, but calling a method that takes a custom class as a parameter fails - with a 'Type Mismatch' error while compiling the VBA code. C# code: ...

Pass an array from vba to c# using com-interop

What is the proper way to pass an array of user defined classes from vba to .net (specifically c#) using com-interop? Here's my c# code. If I call Method1 from vba it's failing with "Array or userdefined type expected" or "Function uses an automation type not supported in visual basic". public class MyClass { public Method1(UserD...

Com Interop Order of Declarations

I have an interface declaration like this: [ComImport] [Guid("79EAC9E4-BAF9-11CE-8C82-00AA004BA90B")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IInternetProtocol { //IInternetProtcolRoot void Start( [ MarshalAs(UnmanagedType.LPWStr) ] string szURL, IInternetProtocolSink Sink, ...

Why is C# null translated as Empty in VB6, instead of Nothing

I have a C# application that reference a VB6 dll. When I pass null from C# into VB6 dll function, the null is translated as value Empty (value) in VB6, instead of Nothing (object). For example: // function in vb6 dll that referenced by c# app Public Sub TestFunc(ByVal oValue As Variant) { ... if oValue is Nothing then set ...

com4j versus jacob to call COM methods from Java

I maintain a legacy Java application that uses Jacob, or Java-COM Bridge, to make calls via the COM interfaces of MS VBA and MS Word. I have been looking at com4j from Sun, and it looks promising. The reason it looks good to me is that it uses vtable binding to methods, instead of IDispatch. Assuming all the COM objects we manipulate pr...

Is the 'Implemented Categories' key needed when registering a Managed COM Component?

When registering a managed class for COM Interop by hand, certain registry keys are needed. For example HKEY_CLASSES_ROOT CLSID\[My Cls Id] InprocServer32 (Default) = "mscoree.dll" Assembly = [My assembly name] etc. I've noticed that when VS registers a library for COM Interop, it also adds a key HKEY_CLASSES_R...

COM object in base class - access via field or property?

I've inherited a codebase of C# dlls that are called via COM-interop (or so it has been described). The C# code also uses COM objects internally to perform the basic functionality of the parent application. I'm refactoring some of the DRY violations out of the code because finding duplications in 100,000 lines of code across 50 or 60 d...

How to mark .NET objects exposed to COM-interop as single threaded?

When defining a COM-visible class in C++ I can define the supported threading model in the header file (the threading(single) line): [ coclass, default(IComInterface), threading(single), vi_progid("Example.ComClass"), progid("Example.ComClass.1"), version(1.0), uuid("72861DF5-4C77-43ec-A4DC-ED04396F0CCD") ] ...

COM Callable Wrapper and .NET object lifetime

I have a c# .NET assembly that gets called from a C++ COM client. When the client process explicitely release the COM object, the CCW release it'sinternal reference, thus making the .NET object eligible for garbage collection. What if the .NET object has a static constructor that open a log file ? Is there an elegant solution to close t...