Hi Ron,
I'll split your questions into three parts.
1. "I understand that for deploying the COM server, we always need to
register the xll file on user's pc, right ?"
There are two ways to do the registration. Either run regsvr32.exe
MyAddin.xll (possibly as part of an installer), or alternatively call
ExcelDna.ComInterop.ComServer.RegisterServer() from your add-in's
AutoOpen, or from a menu item or something. These write exactly the
same registry entries, and can be unregistered the same way.
Registration only writes to HKEY_LOCAL_USER, so there should be no
permissions issues.
Your description of the workflow is right. The same classes that would
have been registered by Regasm will be registered by Excel-DNA, so you
still need some care with [assembly:ComVisble(true)] and to deal with
the ClassInterface issues.
2. " what is the added value ..." / "So what are the advantages in
doing so ? "
(Disclaimer: I am not entirely convinced that this is a useful
feature, and it wasn't my idea.)
But the motivations are to do three things that needed some Excel-DNA
support to be built in:
* You can make RTD servers that can be called directly from the sheet
with =RTD(...) with no wrapper. And such an RTD server can have its
old values preserved (return 'false' for newValues in ConnectData -
see this discussion:
http://groups.google.com/group/exceldna/browse_frm/thread/ad6163ef47ace53d/6743dce0b956d131.
For this to work, don't call XlCall.RTD(...) in your wrapper, but call
the native XlCall.Excel(XlCall.xlfRtd,....).)
* Your COM classes / RTD servers are instantiated in the same
AppDomain as the Excel-DNA add-in, which means your UDFs can share
data with your COM classes. So you can make an alternative way to call
your functions from VBA, nicer than Application.Run, and still have a
shared cache, configuration etc.
* You can pack everything into a single .xll (that does the COM
registration when it is opened).
I suspect this might be a useful feature in putting together a
flexible VBA -> .NET migration story.
3. "did you look for a way of making the xll work without
registering ?"
Indeed. When doing the RTD integration last year, I also tried for a
while to use the registration-free COM interop. After diving into the
manifests and experimenting the the Activation Context APIs, I gave
up. There are two serious complications for using these in the Excel-
DNA case:
* The add-in is running in a 'foreign' process, so I don't want to do
anything that could cause process-wide interactions,
* I wanted to continue with the dynamic structure of the Excel-DNA add-
ins, where a single binary (.xll) is used to load the different add-
ins.
The Activation Context APIs seem like the right interface to use, but
I just couldn't make it fit what I wanted to do.
Initially I didn't want to write to the registry at all. The only
other option I could think of was to install a hook to intercept the
library calls to COM functions like ProgIDFromCLSID. That seemed like
an ugly and dangerous hack, so I didn't even try.
By then I had a look at the registry again, realised I can do all the
COM registration I need under HKEY_LOCAL_USER, so there are no
permission issues, and I saw how much Excel writes to the registry
during a normal session anyway. So I stopped trying to fight obscure
APIs, and just put the stuff in the registry when needed. For the
Ribbon, CTPs and most of the RTD server support, Excel-DNA leaves
nothing in the registry - it writes the entries just-in-time before
the COM classes are loaded be Excel, then deletes those entries again.
For the new COM server support, the COM classes and RTD servers can be
made available to Excel even if the add-in is not loaded. Basically
the .xll replaces mscoree.dll as the unmanaged host for the managed
COM classes.
I hope you have many more questions :-)
Kind regards,
Govert