I made a COM addin for Excel VBA last year. It worked fine with Excel 2010 under Windows 7. Recently, I upgraded to Office 2013 and Windows 8. This addin never worked anymore. I am given a message that says "Run-time error 429. ActiveX component can't create object."
I can see function definitions in Object Browers in VBA. Everything looks fine over there. And the VBA code that instantiates the C# made COM class looks ok as well. I am suspecting either the registration procedure is not compatible or some system settings need to set straight. Please help.
By the way, the C# project's target framework is .net 3.5. I did not change a thing about it. The new system has the framework installed (and rebooted). Also, I made a test project in C# to see if there's some coding errors in the Addin project. The functionality of the Addin works just as expected in test project.
Here's the C# end of code that registers the COM add-in:
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace BlahBlahBlah
{
[Guid("ABCDEFT - I marked off real GUID")]
[ComDefaultInterface(typeof(iFMFunctions))]
[ComVisible(true)]
//[ClassInterface(ClassInterfaceType.AutoDual)]
[ComSourceInterfaces(typeof(iFMFunctionsEvent))]
public partial class Functions : iFMFunctions
{
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
RegistryKey InrpoSrv32Key = null;
InrpoSrv32Key = Registry.ClassesRoot.OpenSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\InprocServer32", true);
InrpoSrv32Key.SetValue("", System.Environment.SystemDirectory + @"\mscoree.dll");
InrpoSrv32Key.Close();
Registry.ClassesRoot.OpenSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\Programmable", true);
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
try
{
Registry.ClassesRoot.DeleteSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\InprocServer32", false);
Registry.ClassesRoot.DeleteSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\Programmable", false);
}
catch { }
}
}
}
Here's VBA end of the code:
Dim aa As New BlahBlahBlah.Functions
Dim d As Double
'd = aa.SOMEREALFUNCTION(100, 100, 0.09, 0.2, 1, True)