What I am trying to do is to create User Defined Functions (UDFs) for Excel using VSTO’s C# “Excel 2007 Add-in”-project type (since I just want to generate some general UDFs
What I've found that works well is to keep the UDF as a VB module to avoid the issues with COM objects.
I've got tons of C# code running and when I'm ready to build the release I do the following:
1. Add a module:
Developer [tab in Excel] | Visual Basic -> project window, right-click, insert module
- merely copy/paste the VB code here
2. Include the appropriate reference library (Tools in same VB window)
3. Save the Excel file as an .xlsm (ie, Macro-Enabled)
You can then delete the .xlsx file.
What I do is zip the entire directory (eg, "Release") and send it to our users.