com

Is there a document on .rgs files syntax?

Resource scripts loaded from .rgs files are used with ATL CComModule::UpdateRegistryFromResource(). It's quite common to see samples of such files on the net but I've never seen a complete description on what constructs are allowed in .rgs files. Is there such a document? ...

VB6 binary compatibility - adding new Events

In a VB6 ActiveX exe project, is there any way to preserve the GUID for the events dispinterface if and when new events are added? Obviously changing existing events breaks compatibility. Adding a new one doesn't cause the VB6 IDE to issue a warning. This doesn't really surprise me, though, as it also doesn't warn when you add new metho...

What does COM exception 80010108 mean?

I am trying to create a PowerPoint presentation from inside a C# .NET application. For the most part it is working, but every once in a while I am seeing this error in my logs: Creating an instance of the COM component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} from the IClassFactory failed due to the following error: 80010108. ...

What is the AppDomainSetup.SandboxInterop Property for?

I am using reading the documentation for app domains in .net 3.5 and came across SandboxInterop. The docs says Gets or sets a value that indicates whether interface caching is disabled for interop calls in the application domain, so that a QueryInterface is performed on each call. But why would I ever wish to disable the caching of Qu...

Outlook VBA script failing with null reference error, but the objects aren't null

I've got an Outlook VBA script which calls on a custom dll to perform a particular function. The assembly is compiled to be COM visible, but is not strong named due because of a myriad of dependencies, and thus is not registered in the GAC. To work around that, I've simply placed the assembly and it's dependencies in the appropriate Pr...

Registering x64 Assemblies for COM Interop

Scenario: I have a project containgin two C# projects, which for historical reasons must communicate with each other using COM (via COM Interop). The COM Server is an in-process automation object (call this the "Server") and the COM Client is a simple C# Console application that loads the server like this: var objTypee = Type....

Is there a way to hook or intercept CoGetClassObject and/or CoCreateInstance calls?

I'd like to intercept the COM CoCreateInstanceEx and/or CoGetClassObject functions to replace a class with a testing shim in a unit test. This will only be for a single CLSID; all others can go through unchanged. Is there a way to do this without horrible, evil hacks? ...

How to Enable ActiveX in Chrome?

I read that early builds of Chrome supported ActiveX, but was later restricted to certain MIME types (for support for say Windows Media Player). I then read Google was going to enable ActiveX strictly for the Korean market. How do I (re)enable this in Chrome? Our web based product relies on ActiveX controls from 3rd parties to play cu...

How to return an array of C# strings (string[]) to unmanaged C++ code?

How to return an array of C# strings (string[]) to unmanaged C++ code, and then use it from C++? // Is it correct ??? [ComVisible(true)] public string[] Foo() { return new string[] {"A", "B", "C"}; } C++ code ?? ...

PInvoke - how to represent a field from a COM interface

I am referencing a COM structure that starts as follows: [scriptable, uuid(ae9e84b5-3e2d-457e-8fcd-5bbd2a8b832e)] interface nsICacheSession : nsISupports { /** * Expired entries will be doomed or evicted if this attribute is set to * true. If false, expired entries will be returned (useful for offline- * mode and cli...

How to Identify a Missing Dependency

We have a legacy 3rd party program that is failing with the error "Class Not Registered" when it tries to execute certain functionality. Is there a way to tell what class it's looking for? Sometimes it says "Catastrophic error" instead. Tried Dependency Walker statically and profiling, Kernal32.exe errors. I'm guessing that's the ins...

C# - EasyHook CoCreateInstance

I'm working the open source library EasyHook. What I'm trying to do, is hook into when a VB6 app calls CoCreateInstance from ole32.dll on a particular CLSID, return my own C# implementation for the object rather than the true COM object. My C# implementation derives from the same interface that tlbimp.exe spits out for the COM object I...

Properly accessing a SafeArray of VT_UNKNOWN with SafeArrayGetElement

We have a COM component who’s implementation and interface definition exist in managed code but is driven by a native component. The managed component is returning a SafeArray back to the native code via the following method declaration. interface IExample { <return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_UNKN...

Why is .NET Sql Server access faster than Excel Interop?

This might be a loaded question, and it might get voted down, but it completely frustrates me. When you use SQL Server in your development the data access is fast and efficient, but when you use COM to talk to Excel it is piggy slow. It doesn't matter what data access technology you use, ADO, ADO.NET, LINQ, Entity Framework, Astoria (A...

How to implement IExplorerBrowser in MFC

Apparently, there's a fairly easy way to host Explorer in your app starting with Vista: http://www.codeproject.com/KB/vista/ExplorerBrowser.aspx However, that interface is only available starting with Vista. I see that there is another way to do it: "going all the way back to 95, but it requires more work - implement IExplorerBrowser a...

Need a good book(s) and information about working with unmanaged code and COM with .Net

I have been working with .Net since VS2002 and since then any time that I had to work with COM or unmanaged code has been a pain. I've succeeded doing what was expected but almost always doing a trial-error procedure. I've had enough of this and I want to know what's going on at the back room and understand how those things work. As us...

Upcasts in COM automatic?

In COM, if I have an interface IBase and an interface IX which inherits from IBase, can I call methods of IBase through an IX pointer, and if not, why can I call Release() and AddRef() on any COM interface pointer without an upcast? ...

How to fix COM outproc server initializing error 0x80004015?

I have a COM outproc server written in ATL that registers itself using _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE) and it results in an HRESULT error code 0x80004015 (which means CO_E_WRONG_SERVER_IDENTITY). What causes this error code, and how can I work around this error? ...

Large Xml files are being truncated by MSXML4 / FreeThreadedDOMDocument40 (COM string Interop issue)

I'm using the following code to load a large Xml document (~5 MB): int _tmain(int argc, _TCHAR* argv[]) { ::CoInitialize(NULL); HRESULT hr; CComPtr< IXMLDOMDocument > spXmlDocument; hr = spXmlDocument.CoCreateInstance(__uuidof(FreeThreadedDOMDocument60)), __uuidof(FreeThreadedDOMDocument60); if(FAILED(hr)) return FALSE; spXmlDoc...

What is the preferred method of marshalling COM interfaces across threads?

What are the pros/cons of using the GIT as opposed to CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream for marshalling COM interfaces across threads? Are there strong reasons for preferring one method over the other, or is it more a matter of personal preference? ...