Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike S - 25 Jul 2007 02:16 GMT
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
Mike S - 25 Jul 2007 02:46 GMT
> 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-us/library/
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 - 27 Jul 2007 19:49 GMT
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.
Signature

Phil Wilson
[MVP Windows Installer]

>> 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
[quoted text clipped - 25 lines]
> --
> Mike S

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.