Mike S
7/25/2007 1:16:00 AM
OK, I used to think I understood what RegAsm was for: if you are
exposing a .NET assembly to COM, you RegAsm the assembly to add all of
the necessary COM entries to the registry so that the COM runtime can
instantiate your ComVisible .NET classes - I thought that was the *one
and only* scenario where you needed it (because why else would you
need COM registration entries unless you wanted COM clients to see
your .NET classes???)
Now I'm seeing various MSDN pages and blog posts suggesting that
Primary Interop Assemblies should be RegAsm'ed for one reason or
another, with no real explanation as to why they need to be.
I guess I'm confused because a PIA is wrapping an existing COM
component that will be used from .NET, so why the heck do you need the
extra meta-data in the registry that RegAsm will add to the existing
COM entries? Shouldn't registering the original COM component be
enough?
The extra meta-data makes perfect sense when you're RegAsm'ing a .NET
component that is being exposed to COM, because in that case
mscoree.dll is registered as the COM server and thus the CLR obviously
needs additional information to load your .NET assembly and the
necessary types when a COM client tries to instantiate your class(es),
but what purpose does this extra meta-data serve when you register a
PIA? The PIA is already referenced by the .NET assembly that is using
the corresponding COM component, so the registry entries seem
superfluous, since the referencing assembly already knows where the
PIA is...
So, a few questions:
1. Should you always RegAsm Primary Interop Assemblies?
2. WHY do you need to RegAsm them in the first place?
3. What about non-primary Interop Assemblies? Do they get
RegAsm'ed?
--
Mike S