Developing Excel Functions in C# for Excel 2010 64-Bit

Lately I needed to write a small “add-in” for Excel that adds a function written in C# (another case of “when your 4 years of office add-in development experience comes back to haunt you”). Before going ahead with that I searched the web for a quick how-to and ran into this old but still relevant blog post by Eric Carter.

I did everything Eric had described, but every time I tried to add the add-in through the Automation Servers dialog I just couldn’t find it in the list. Trying to locate the file through the Browse button resulted in the next window:

The file you selected does not contain a new Automation Server, or you do not hace sufficient privileges to register the Automation Server.

Such a sweet little message that tells you so much and at the same time tells you nothing at all. How can’t you love developing for Office?

After a couple of hours fighting it with everything I knew (run as admin, installing through a setup project, rewriting everything and more) just when I was ready to throw the laptop out the window and wait for Chrome OS to come out, the brilliant mind of Eran Stiller came up with the question – “maybe it’s related to some 64-32 bit stuff”.

Facepalm. Head-to-desk. Facepalm again. Of course it was related!

As you can understand, I have Excel 2010 64bit installed on my machine. And that’s the root of all my problems. Yes, each and every single one of them.
Anyway, To get the addin working on my machine I had to manually register the DLL using the .NET framework’s 64bit regasm utility. If you also have the same problem, follow the next steps to solve it:

  1. Follow all the steps in Eric Carter’s blog post.
  2. Open the project’s properties and uncheck the “Register for COM Interop” checkbox (I actually don’t think it really matters but just in case).
  3. Rebuild the project.
  4. Open cmd (open Start->Run, type “cmd” and hit Enter).
  5. Navigate to %windir%\Microsoft.NET\Framework64\v4.0.30319
  6. Run: regasm /codebase <path_to_dll>\MyAssembly.dll
    Pay attention to the /codebase switch – without it, it won’t work!

That’s it, you’re done. Your command prompt would look similar to that:

regasming the assembly

[Notice that you’ll get a warning here that the assembly is not signed. If you’re writing a real product, make sure you sign it!]

After that, open Excel and add your DLL again (according to the instructions in Eric’s post). After you do that, try using your functions!

I’m adding my sample project here (which works for me) and its output assembly so you can play with it:

Project (5Kb)
Assembly (4Kb)

Let me know if something isn’t clear or doesn’t work for you.

All the best,
Shay.




Comments

January 5. 2011 06:34 PM

Peter

Thousands of thanks! I finally let it work. Appreciate your helps!
=Peter

Peter

January 7. 2011 06:11 AM

Rushwire

Thanks - I too struggled with this for a couple of hours before stumbling on your solution. Worked like a charm.

Rushwire

January 10. 2011 03:08 PM

TR

Hey man,
thank you VERY much. Had the same problem minus the 4 years of general experience in the area - speant at least 10 hours trying different examples which all didn't work because of that.

THANK YOU

TR

May 20. 2011 07:11 PM

Maurice Calvert

Many thanks, I was pulling my hair out!

Maurice Calvert

March 1. 2013 03:09 AM

Leon

Thanks a million!

Leon

March 19. 2013 06:48 AM

Radar Towers

Hey just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same outcome.

Radar Towers

March 29. 2013 03:49 PM

onur omer ozturk

Marvelous!!!! after searching for many hours you have saved my life! /Codebase did the trick!!

onur omer ozturk

April 21. 2013 05:43 PM

pingback

Pingback from word.deveronline.com

Excel Add-in not show up in 64 bit Excel (Add-In Express) | Excel Tips | Word Tutorials

word.deveronline.com

May 15. 2013 02:26 AM

loie

I followed the steps here and you're right..thanks for the brilliant idea!



www.spywarenews.org/.../top-10-passwords-you-must-stop-using

loie

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Subscribe Subscribe

That's Me!

Hi! I'm Shay Friedman
I'm Shay Friedman - a Visual C#/IronRuby MVP, a consultant and instructor of .NET technologies, author, speaker and new technologies freak
More about me

Contact Me

> Contact page
> Twitter: @ironshay
> LinkedIn profile

Search

Hosted By

I'm hosting this site on Arvixe and I'm very happy with it.
If you're looking for ASP.NET hosting, I highly recommend it
(and if you order from this link I also get some beer money!)
Web Hosting