Question

I want to create a VS2010 c# class that can be used in a Vb6 project. I've done simple C# class below and ticked the "register for com interop" in the build properties. In the Vb6 project I can see a reference for ComTestC but when I run the vb6 code I get:

run-time error '429' ActiveX component can't create object

I'm I missing an obvious step to getting this Com object working?

Vb6 Code

Private Sub Command1_Click()

Dim foo As Object
Set foo = CreateObject("ComTestC.Numbers")

End Sub

C# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ComTestC
{
    public class ComTestC
    {

        [Guid("8b8d1e17-fc8e-4316-afb7-394a5da56801")]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        public interface _Numbers
        {
            [DispId(1)]
            int GetDay();

        }

        [Guid("68d6c981-66dd-4731-93a0-2c39bd86495f")]
        [ClassInterface(ClassInterfaceType.None)]
        [ProgId("ComTestC.Numbers")]
        public class Numbers : _Numbers
        {
            public Numbers() { }

            public int GetDay()
            {
                return (DateTime.Today.Day);
            }

        }


    }
}
Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top