com-interop

Calling .Net Classes from Visual Basic 6

Hi, I have a .net dll file. I have to call one of the methods in this dll file from a VB program. This dll file uses another .net dll file for logging purpose. I able to call a .net class library method from VB6 application. But, I am getting the exception that unable to load assembly (which is used for logging). How the vb6 applica...

CoInitialize() / CoUninitialize() calls pairing

I have a single-threaded application that uses COM objects. At the beginning I in effect call CoInitialize(0) twice - once in my code and the second time in the code of another subsystem of the application. The first call returns S_OK, the second returns S_FALSE - exactly as MSDN says. When the application stops it calls CoUninitialize(...

GPLv2 or GPLv2 compatible Windows 7 TaskBar library?

I wish to integrate the new Windows 7 Taskbar Features into a GPLv2 licensed open source project (EVEMon). Microsoft's excellent Windows API Code Pack would work well however it is licensed under MS-pl which is incompatible with the GPLv2. I have found a Windows 7 Taskbar project on CodePlex, licensed under the MIT Licence which is GPLv...

managed client of a COM server threw InvalidCastException

I registered my very simple native COM server and my native COM client can call the COM method successfully. However, my managed COM client threw below error: Unable to cast COM object of type 'DevicesLib.MyComClass' to interface type 'DevicesLib.IMyComInterface'. This operation failed because the QueryInterface call on the COM componen...

Releasing temporary COM objects

Consider the following C# code using a COM object. MyComObject o = new MyComObject; try { try { var baz = o.Foo.Bar.Baz; // do something with baz } finally { Marshal.ReleaseComObject(baz); } } finally { Marshal.ReleaseComObject(o); } This will release the COM objects o and baz, but not the temporary objects returnd by...

Excel get_Range missing when interop assembly is embedded in .NET 4.0

I build an assembly referencing a COM interop DLL. If I embed the COM interop types by setting Embed Interop Types to True in the Reference's properties (VS2010), at run-time an error occurs "object does not contain a definition for get_Range". If COM interop types are not embedded then no error occurs. Does anyone know why a particul...

C# COM server access from JScript

I have a COM server, implemented in C#. It exposes a class decorated like this: [ComVisible(true)] [ProgId("MyServer.MyClass")] [ClassInterface(ClassInterfaceType.AutoDispatch)] I registered the DLL with "regasm /codebase MyServer". This server must be used from a WSC (a COM server implemented in JScript). Therefore I used the AutoDis...

Is it possible to intercept (or be aware of) COM Reference counting on CLR objects exposed to COM

I have rephrased this question. When .net objects are exposed to COM Clients through COM iterop, a CCW (COM Callable Wrapper) is created, this sits between the COM Client and the Managed .net object. In the COM world, objects keep a count of the number of references that other objects have to it. Objects are deleted/freed/collected whe...

How can I wrap a COM object in a native .NET class?

I'm using an extensive existing COM API (could be Outlook, but it's not) in .NET (C#). I've done this by adding a "COM Reference" in Visual Studio so all the "magic" is done behind the scenes (i.e., I don't have to manually run tlbimp). While the COM API can now be "easily" used from .NET, it is not very .NET friendly. For example, th...

Problems invoking methods on a COM thread from a WinForms GUI thread?

I'm having trouble with my COM component written in .NET throwing warnings that look like: Context 0x15eec0 is disconnected. No proxy will be used to service the request on the COM component. This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the app...

IronRuby: Cannot call method on a COM Object with one or more arguments.

When I try and call any method on a COM Object that takes one or more arguments, I get the following error on the last argument: Could not convert argument 0 for call to Open. (ArgumentError) Everything works fine when calling a method that takes no arguments, or getting/setting a property. Here is the code that gives me the error abo...

"Parameter is incorrect" error when invoking .NET assembly via COM component

Hello all! I have a .NET assembly that lives in the GAC. It is registered correctly so that it can be invoked by COM components. This .NET assembly contains a method and an overload to the method: public void Foo(string sValString, out string sOutString, string sOverloadString) { if( sOverloadString == string.Empty ) // d...

COM Interop .Net - Out of Memory/BUFFER OVERFLOW error when executing asm method

This is a strange one. For a long time now an application I develop on has been using com interop to use .Net types in an Classic ASP application. I fired this application up again today to look at some issue with it got an Out Of Memory error when accessing a method on one of these objects. Fine - I thought, I'll just unregister the ...

How to Access/marshall char *variable from dll import in C#

Hi I need to access functionality from win32 dll , for that I am using [dllimport] in C# code. what exact method signature i need to create with [dllimport] for the following c++ methods void GetGeneratedKey(char *code, int len, char *key) pls help in this. Thanks nRk ...

How to Register a Type Library without RegAsm.exe

I want to know if it's possible to register a type library without using the RegAsm tool. Here is my situation, which will hopefully explain why I want to do this: I'm developing an assembly in .NET that will provide some modern functionality for our older VB6 applications. I have successfully registered the assembly and the type libr...

VB.net interface won't compile, why ?

Question: I'm trying out to convert this here: http://support.microsoft.com/kb/828736 to VB.net I got it to work in C#, and it should work without problems in VB.net, the only problem is the managed class won't compile, i get this error: Error Class "ManagedClass" has to implement "Function Add(Number1 As Integer, Number2 As Integer) As...

Register a C#/VB.NET COM dll programatically

Question: I have a .NET dll which I use from a C++ program. Now I have to register the dll programmatically on a deployment computer. How do i do that (programmatically! not using regasm) ? I remember, when I once called a VB6 dll from a C++ dll, I had to use DllRegisterServer and DllUnregisterServer. Is that still so with a .NET dll...

Am I calling a .NET object or a COM object?

An interesting question arose today. Let's say I have a .NET object that implements a certain interface IMyInterface and is also COM Visible. Now, I load the type from its ProgID and cast to a strongly-typed interface, like so: IMyInterface objEarlyBound = null; Type t = Type.GetTypeFromProgID("My.ProgId"); objLateBound = Activator.Cre...

CAB file for X86 and X64

HI I have created a CAB file for an ActiveX component which is wrapper around a .Net Libray. Here the .Net Library is refering some third party components which are actually build in (X86 or X64) No Any CPU. So My Cab file should be intelligent enogh to install eigther X86 or X64 depending on the client ( Browser) I Know the change ...

Is a COMException of 0x80040154 always 'Class not registered'?

Does a System.Runtime.InteropServices.COMException of 0x80040154 always mean that the class isn't registered? I'm getting a COMException which says "Retrieving the COM class factory for component with CLSID {29131539-2EED-1069-BF5D-00DD011186B7} failed due to the following error: 80040154." It's trying to load Interop.Domino.dll which ...