Getting ScriptControl to work with Excel 2010 x64

You can create ActiveX objects like ScriptControl, which available on 32-bit Office versions via mshta x86 host on 64-bit VBA version, here is the example (put the code in a standard VBA project module): Option Explicit Sub Test() Dim oSC As Object Set oSC = CreateObjectx86(“ScriptControl”) ‘ create ActiveX via x86 mshta host Debug.Print TypeName(oSC) … Read more

How does the C# compiler detect COM types?

By no means am I an expert in this, but I stumbled recently on what I think you want: the CoClass attribute class. [System.Runtime.InteropServices.CoClass(typeof(Test))] public interface Dummy { } A coclass supplies concrete implementation(s) of one or more interfaces. In COM, such concrete implementations can be written in any programming language that supports COM component … Read more

StaTaskScheduler and STA thread message pumping

My understanding of your problem: you are using StaTaskScheduler only to organize the classic COM STA apartment for your legacy COM objects. You’re not running a WinForms or WPF core message loop on the STA thread of StaTaskScheduler. That is, you’re not using anything like Application.Run, Application.DoEvents or Dispatcher.PushFrame inside that thread. Correct me if … Read more

Error ASP 0177: 8007007e CreateObject fails for COM DLL

The advice below relates to both Server.CreateObject and CreateObject use in vbscript jscript vba The Web Server sections are specific to asp-classic but still worth reading. What Causes This error? Server.CreateObject Failed is caused most commonly when Web Applications are moved from one Web Server to another without an understanding of external COM components that … Read more

How to handle AccessViolationException

EDIT (3/17/2021) Disclaimer: This answer was written in 2011 and references the original .NET Framework 4.0 implementation, NOT the open-source implementation of .NET. In .NET 4.0, the runtime handles certain exceptions raised as Windows Structured Error Handling (SEH) errors as indicators of Corrupted State. These Corrupted State Exceptions (CSE) are not allowed to be caught … Read more

Could you explain STA and MTA?

The COM threading model is called an “apartment” model, where the execution context of initialized COM objects is associated with either a single thread (Single Thread Apartment) or many threads (Multi Thread Apartment). In this model, a COM object, once initialized in an apartment, is part of that apartment for the duration of its runtime. … Read more