Like the subject says, I wrote a C# class, say Test, then compiled it as a DLL and exposed it to Excel as a COM automation server. Now, you can call the methods of that class in Excel formulas either directly or through a VBA function that itself calls them under the hood. What happens in the second case is relatively transparent (you wrote the code!) while in the first case I assume a Test instance is transparently instantiated and then used (it has to since the exposed methods are not and -- from what I have read -- cannot be static) but exactly when and how is unclear. Thus my question is: what is the precise life cycle of an automation server called in this setting and where is that documented?
A subsidiary question is whether there is a way to make both direct calls in formulas and calls via VBA use a single singleton instance of Test? I think I already know how to get all the VBA procedures to use a single Test instance but even so a second one is created whenever a Test method is called directly in a formula.
Lastly, if that Test class holds resources at the class level (i.e., static resources), when and how should you dispose of them? Again, that begs the question of exactly when Test classes are created and destroyed by .Net/COM Interop.
Precision: the service is a DLL, not an application, and Excel should be the only thing using it, although there might be more than one copy of the spreadsheet open. This is Excel 2007.