[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Regasm is for ComVisible .NET Assemblies -AND- PIA's???

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

2 Answers

Mike S

7/25/2007 1:47:00 AM

0

On Jul 24, 9:16 pm, Mike S <mgspr...@netscape.net> wrote:

> 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?

Well, I'm going to answer a portion of my own post - I should've read
the "official" PIA primer on MSDN before posting...

What what I just read (http://msdn2.microsoft.com/en-u...
aa302338.aspx), a PIA needs to be RegAsm'ed so that Visual Studio can
reference the PIA instead of generating a new IA when you add a
reference to a COM component that has a PIA associated with it. I sort
of suspected the extra registry keys were being used by the IDE, and
not by the CLR per se.

But I'm still a bit confused. Since it seems like these extra registry
entries are only used by the IDE to differentiate between plain old
COM components and those that have PIAs, I wondering if I need to
RegAsm the PIA's when I deploy components to a client machine. That
is, in a compiled .NET assembly using the COM classes defined in the
PIA, the assembly will already be referencing the PIA, so do I need to
RegAsm the PIA on the client machine, or is installing the PIA's
assembly file to the GAC enough? It seems like the extra registry
entries are just there to so that the IDE can locate any PIA's while
it's enumerating the keys under HKLCR\TypeLib...

--
Mike S

Phil Wilson

7/27/2007 6:49:00 PM

0

I think you're right. In a deployment situation where a PIA (or any interop
assembly) is being used by an app there's no need to register it. In fact
I've seen people mistakenly register interop assemblies (with regasm) only
to find that it affects the actual registration of the COM class it's
mapping, so unregistering the interop assembly then destroyed the COM
registration.
--
Phil Wilson
[MVP Windows Installer]

"Mike S" <mgspross@netscape.net> wrote in message
news:1185328003.968158.92480@g4g2000hsf.googlegroups.com...
> On Jul 24, 9:16 pm, Mike S <mgspr...@netscape.net> wrote:
>
>> 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?
>
> Well, I'm going to answer a portion of my own post - I should've read
> the "official" PIA primer on MSDN before posting...
>
> What what I just read (http://msdn2.microsoft.com/en-u...
> aa302338.aspx), a PIA needs to be RegAsm'ed so that Visual Studio can
> reference the PIA instead of generating a new IA when you add a
> reference to a COM component that has a PIA associated with it. I sort
> of suspected the extra registry keys were being used by the IDE, and
> not by the CLR per se.
>
> But I'm still a bit confused. Since it seems like these extra registry
> entries are only used by the IDE to differentiate between plain old
> COM components and those that have PIAs, I wondering if I need to
> RegAsm the PIA's when I deploy components to a client machine. That
> is, in a compiled .NET assembly using the COM classes defined in the
> PIA, the assembly will already be referencing the PIA, so do I need to
> RegAsm the PIA on the client machine, or is installing the PIA's
> assembly file to the GAC enough? It seems like the extra registry
> entries are just there to so that the IDE can locate any PIA's while
> it's enumerating the keys under HKLCR\TypeLib...
>
> --
> Mike S
>