0
votes

I have built a .NET COM wrapper which I use in VBA to run a .NET assembly in Excel.

For some reason I can't use late-binding to create objects from the .NET COM dll.

Set obj = CreateObject("COMwrapper.MyClass")

This throws

Error 429: ActiveX component can't create object

It works however if I:

  • Use early-binding and reference the COMwrapper.tlb
  • Run Excel with admin rights

The COMwrapper .NET project and it's dependencies .NET DLLs are built with Visual Studio 2019 elevated to admin mode, so that it can register the COMwrapper in the build process.

I have also tried to build the solution with VS as normal user, without registering the COM wrapper. Later manually I have run regasm.exe with admin rights. But it has been the same result.

If I peek into the registry with RegDllView.exe (https://www.nirsoft.net/utils/registered_dll_view.html), the COMwrapper DLL seems to be registered and with the right path.

This is how I have set up the COM part

The class file

namespace COMwrapper
{
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    [Guid("904EBB3C-7A28-490E-B2E5-0CC0C66E907A")]
    public class MyClass : IMyClass

The interface file

namespace COMwrapper
{
    [Guid("540D119F-6676-4CE9-B763-50F4F2976E1E")]
    [ComVisible(true)]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface IMyClass

This has previously worked fine! If I distribute the DLLs to another computer and register the wrapper, it works fine with late binding.

1
Can you show any of the C#, not neccessarily the code, the set up of [ComVisible] etc. Does Set obj = CreateObject("COMwrapper") give the same error? - Nathan_Sav
@Nathan_Sav Yes the same problem remains with set obj = CreateObject("COMwrapper"). Can't find the [ComVisible] option in the .proj file but I have that set as true in Visual Studio 2019 project settings for the COMwrapper. - Johan A
Was indeed a registry corruption issue. Ran CCleaner and afterward it worked fine. - Johan A

1 Answers

0
votes

Not an answer, just supporting my comment. I created a DLL in Admin rights on VS2019, and was able to access via both early and late binding. This is how i set it up

enter image description here