Visual Studio – TYPE_E_REGISTRYACCESS

When setting Register For Com interop I’ve found that you do need to run as Administrator. Without Administrator trying to compile I got errors like: Cannot register assembly “C:\TFS\Project\Src\ProjectAddin\bin\Debug \ProjectAddin.dll” – access denied. Please make sure you’re running the application as administrator. Access to the registry key ‘HKEY_CLASSES_ROOT\CLSID{3A6192EA-3C9C-39EB-99A3-3DBFF8CA118F}’ is denied. The above registry key didn’t … Read more

Handling events from out-of-proc COM server in managed STA application

I’ve found the following excerpt from Adam Nathan’s “.NET and COM: The Complete Interoperability Guide”: If the COM object lives in an STA, any calls from MTA threads are marshaled appropriately so the COM object remains in its world of thread affinity. But, in the other direction, no such thread or context switch occurs. Thus, … Read more

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

To add to the already existing answers: with .NET 4.0, it’s actually quite simple to consume a C# dll in your VBA project without registering the COM. EDIT: I just tried this with the mscorlib.tlb and mscoree.tlb that are in C:\windows\Microsoft.NET\Framework\v2.0.50727— loading an assembly compiled in 3.5– and it worked just fine. So apparently you … Read more

Building a COM interop library for ASP Classic using 4.0 framework and Visual Studio 2010

It should be fairly straightforward to get a basic .NET assembly exposed to COM – I’ve never tried the COM Class project template, so this is the way I’ve managed it in the past: Create a new (bog standard) .NET class library using C# or VB. Define a COM interface (replace GUIDs with your own): … Read more