I'm trying to figure out how to solve this. I tried many things that I saw on internet but with no success. I tried: to use regasm, compile target as x86, dumpbin dll /t:dll.tlb, change the version of Framework etc.
I have two machines (M1 and M2) both with windows 7 64 and VS2012. When I develop a COM in M1, it runs fine in VBA of M1. But it doesn't work for M2 (Error 429). Then, if I go to M2 and write a new COM, it works fine in VBA of M2, but not for M1.
It seems that VS2012 is performing a "hidden" registration step that I can't see. Does someone know how to find that?
Many thanks! Below is my "COM Hello World". I'm using Register for COM interop as well.
UPDATE:
If I run:
C:\windows\Microsoft.NET\Framework\v4.0.30319\regasm TesteLib.dll /TesteLib.tlb
the 429 error disappears. But now, instead of error 429, I'm getting "error -2147024894 (80070002) Automation Error" in the same line.
I followed the solution from Can't instantiate a COM object written in C# from VBA (VB6 ok) to create a Excel.Exe.Config inside EXCEL.exe folder and my program runs fine now. But I think that I can't perform this on client machines. Is there an alternative to that?
Also, it works ok in VB6 (without the need to perform the REGASM).
.net side
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace TesteLib
{
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("c6b093c6-f568-4962-8955-795fc14f34bb")]
[ComVisible(true)]
public interface ClassInt1
{
int sum(int a, int b);
}
[ClassInterface(ClassInterfaceType.None)]
[Guid("19ff9b41-8652-4012-ac55-c1a1d8f18cbb")]
[ComVisible(true)]
[ProgId("TesteLib.Class1")]
public class Class1 : COMException, ClassInt1
{
public int sum(int a, int b)
{
return a + b;
}
}
}
VBA side
Sub t()
Dim r As TesteLib.Class1
Set r = New TesteLib.Class1 'Run-time error '429': ActiveX component can't create object
MsgBox r.Sum(35, 51)
End Sub