com-interop

VB6 event passing bool argument that's always 'true' in C#

北城余情 提交于 2019-12-04 15:20:58
My problem is simple, I have an event declared in a VB6 library that passes out a boolean argument: Public Event WriteComplete(ByVal aCommsOk As Boolean, ByVal aBadPIN As Boolean) I have hooked my c# code up to this event many times but bizarrely my testing department and a couple of other ppl have noticed that although VB6 raises this event with aBadPIN set to false, the c# event handler receives it as true. It is not consistent so it's one of 'those' problems but I'm not finding anything on the internet to help much. I have found that if I define a new event that converts the bool to a byte

How exactly do I config DCOM to load my DLL into a separate process?

十年热恋 提交于 2019-12-04 15:05:23
I'm trying to force an existing native C++ ATL in-proc COM server into a separate process. I hope DCOM can do this for me without changing the COM server. I started with a usual registry setup - I have a HKCR\CLSID{classId} entry and an InProcServer32 key there specifying the path to the .dll file. I generated an application id (GUID) and added it here and there. Specifically I added a string value "AppId" under HKCR\CLSID{classId} equal to the application id. I also added a HKCR\AppId{applicationId} key and a string value "DllSurrogate" equal to an empty string. I thought it would be enough

Application hanging during CoCreateInstance of .NET-based COM object

被刻印的时光 ゝ 提交于 2019-12-04 15:02:38
I have a C++ DLL that is creating an instance of a COM object that's implemented in .NET. Under many circumstances this works fine, but under certain circumstances, it hangs the application, and I see it stuck with the following call stack (this is just the part underneath the level of my DLL's code): ntdll.dll!_NtAlpcSendWaitReceivePort@32() rpcrt4.dll!LRPC_CASSOCIATION::AlpcSendWaitReceivePort(unsigned long,struct _PORT_MESSAGE *,struct _ALPC_MESSAGE_ATTRIBUTES *,struct _PORT_MESSAGE *,unsigned long *,struct _ALPC_MESSAGE_ATTRIBUTES *,union _LARGE_INTEGER *) rpcrt4.dll!LRPC_BASE_CCALL:

Register managed assemblies with COM without using the GAC

泪湿孤枕 提交于 2019-12-04 14:16:52
问题 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. 回答1: Yeap, use regasm.exe with /codebase key for that. When you use regasm.exe without /codebase it only writes the filename of the assmebly to the registry and so the .NET runtime can't find it unless the assembly is in the GAC. With /codebase it will write the full path and

How to properly clean up Excel interop object in C#, 2012 edition

依然范特西╮ 提交于 2019-12-04 13:17:26
问题 I am in the process of writing an application in C# which will open an Excel spreadsheet (2007, for now) via interop, do some magic, then close. The "magic" part is non-trivial, so this application will contain many references to many COM objects spawned by Excel. I have written this kind of application before (too many times, in fact) but I've never found a comfortable, "good smell" approach to interacting with COM objects. The problem is partly that, despite significant study, I still don't

Difference between Dual interface and Dispatch only interface for C# COM automation

假如想象 提交于 2019-12-04 12:58:12
I am implementing a c# COM client against a C++ COM server. The COM client functions correctly when I mark the COM interface as "Dual" but it throws an InvalidCastException when I remove the "Dual" attribute. Therefore the easy fix for me is to mark it as Dual. But from reading online, it looks like it is not the recommended approach to use for COM servers. Can anyone explain to me the significance (in layman terms) to marking an interface as dual and why it would not be recommended? I only need it for testing purposes, and I'm using C# client (don't anticipate that I ever will use VB)

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

怎甘沉沦 提交于 2019-12-04 12:10:55
问题 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 these COM related assemblies to be loaded in the wrong AppDomain? Please see a more detailed description of the situation below... The application consists of 3

How to return a JavaScript 'native' array from a C# method?

…衆ロ難τιáo~ 提交于 2019-12-04 11:52:50
问题 I'm trying to call a C# method from JavaScript by using ActiveXObject : var myobj = new ActiveXObject('myobject'); var arr = myobj.GetArray(); Eventually, arr will contain a SAFEARRAY object, but not JScript array. Is there any way to return native JavaScript object from a C# method? 回答1: You can return a JSON string and then parse into a JavaScript object. There are a number of .NET libraries available to serialize .NET objects into JSON and vice-versa- JSON.NET Microsoft ASP.NET AJAX

Embed a Registration-Free COM manifest into a C# dll with native/managed environment

一笑奈何 提交于 2019-12-04 11:13:07
I'm currently working on a mixed native / managed application chain, which employs registration-free COM. The following image illustrates this: The C# wrapper DLL has been created using the tlbimp.exe utility. This allows each of the C# executables to access the native types and methods in the COM DLL. The COM DLL itself employs a server based RegFree COM manifest. Everything works fine, when the client based RegFree COM manifests are embedded in the C# executables. However, I would like to move and unify these manifest files into the C# DLL, which would ease maintenance and synchronization of

Expose dll for COM Interop

佐手、 提交于 2019-12-04 11:09:48
问题 I thought I knew how to do this, but obviously not so I'd appreciate some help! I can't get my dll to register so I can instantiate it in a VBS, or elsewhere. I wrote the following sample class, checked "Make assembly COM Visible", checked "Register for COM Interop", then built it. When I try to instantiate it from VBS I get the "Activex component can't create object" error. This is the class code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace