Excel 2010 64 bit can't create .net object
Posted
by aboes81
on Stack Overflow
See other posts from Stack Overflow
or by aboes81
Published on 2010-04-27T19:31:30Z
Indexed on
2010/04/27
19:33 UTC
Read the original article
Hit count: 301
I have a simple class library that I use in Excel. Here is a simplification of my class...
using System;
using System.Runtime.InteropServices;
namespace SimpleLibrary
{
[ComVisible(true)]
public interface ISixGenerator
{
int Six();
}
public class SixGenerator : ISixGenerator
{
public int Six()
{
return 6;
}
}
}
In Excel 2007 I would create a macro enabled workbook and add a module with the following code:
Public Function GetSix()
Dim lib As SimpleLibrary.SixGenerator
lib = New SimpleLibrary.SixGenerator
Six = lib.Six
End Function
Then in Excel I could call the function GetSix() and it would return six. This no longer works in Excel 2010 64bit. I get a Run-time error '429': ActiveX component can't create object.
I tried changing the platform target to x64 instead of Any CPU but then my code wouldn't compile unless I unchecked the Register for COM interop option, doing so makes it so my macro enable workbook cannot see SimpleLibrary.dll as it is no longer regsitered.
Any ideas how I can use my library with Excel 2010 64 bit?
© Stack Overflow or respective owner