Scott Hanselman

"Gotchas" around Primary Interop Assemblies and the GAC

June 10, 2003 Comment on this post [0] Posted in Web Services | Tools
Sponsored By

A couple of things to be aware about when working with PIAs, particularly when deploying them.  PIAs provide a unique type identity for COM Components.  They provide a single place for your .NET app to interop with existing COM objects.  They get marked with the PrimaryInteropAssembly attribute...if there's any question about an assembly, you can ILDASM it and see the PrimaryInteropAssembly attribute in the Manifest. 

You can create a "vanilla" PIA with TLBIMP.exe like this (note the /primary key):

TlbImp MyCom.tlb /primary /keyfile:MyKey.snk /out:MyPIALib.dll

If you want to create a custom PIA, perhaps to marshal types a specific way you'll apply the attributes from source:

[assembly:Guid("xxxxxxx-xxxx-xxx-xx-xxxx-xxxx"]
[assembly:PrimaryInteropAssembly(3, 1)] //Version 3.1

Of course the COM Object that you're referring to has to be registered, but the PIA has to be as well.  You'll need to call RegASM.exe to create a key in the registry under HKEY_CLASSES_ROOT\TypeLib\{yourclassid}\PrimaryInteropAssemblyName.  The value of this key should be the fully qualified Assembly name like: MYDLL, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.  Some folks call RegASM, others ship a .REG file or create this key during the installation procedure.

To recap:

  • Register COM Object (if not already)
  • Create InteropAssembly with TLBIMP.EXE and /primary (make sure it's strongly named)
  • RegASM the resulting InteropAssembly
  • Put the PIA in the GAC

Note also that when referencing your PIAs in Visual Studio.NET via "Add Reference..." you won't find your PIA in the .NET Tab as some may think.  Just select the original COM TLB/DLL reference from the COM Tab and Visual Studio will silently search for and use the PIA.  You can confirm this by looking at the added reference in the Properties Toolbox and confirming that it's strongly named.

Also check out Sam Gentile's article about Programmating Determining if a PIA in in the GAC and Mattias' page on the Fusion APIs.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Leaning at the Tape...a B.S. in Software Engineering squeezed into 11 short years...

June 06, 2003 Comment on this post [7] Posted in Web Services | TechEd | Speaking
Sponsored By

Thanks Tomas, for noticing my MSN Messenger name had been updated to reflect my College Graduation tonight!  I'm getting a B.S. in Software Engineering from OIT and it only took 11 years.  The ceremony is at OIT in Portland on 185th and Walker at 7pm.  I'm one of the students who has been asked to say a few words - which is nice since I've "outlived" four department heads.  Even more exciting is that I've joined the staff as an adjunct to teach C# this fall, one of only two professors without Master's Degrees. 

This has been an amazing week with TechEd, Graduation, and this teaching opportunity all at once.  Thanks to everyone who has supported me this past year.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

TechEd 2003: Dallas : Going Home...

June 04, 2003 Comment on this post [2] Posted in Web Services | TechEd | Speaking | PDC | Tools
Sponsored By

I had a BLAST at TechEd this year.  Thanks to everyone who made my session DEV389 - Learning to Love WSDL a standing-room-only session!  A lot of great comments, a lot of good discussion.

If you're looking for code samples, the slides, snippets, links, etc look at my earlier post on Web Services Tools from the Windows Server 2003 Launch and the MyMsEvents site.

Thanks to everyone and see you at PDC!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

TechEd 2003: Dallas : Day 3 - The Calm before the storm...

June 04, 2003 Comment on this post [0] Posted in Web Services | TechEd | Speaking
Sponsored By

It's the quiet hours before my session...the demos are ready, the laptop is stable (knock on wood) and I'm ready to jump in...it's Learning to Love WSDL - DEV389 at 1:30 in C147/C148/C154 - the only session with "love" in the title.  Wish me luck!

Also, kudos to Kate Gregory for having the highest rated session at TechEd so far!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

TechEd 2003: Dallas : Day 1 - The Afterparty

June 02, 2003 Comment on this post [0] Posted in Web Services | ASP.NET | TechEd | Speaking
Sponsored By

Day 1 of TechEd is really just the Afterparty of the Sunday events.  We hung out at the Circle R ranch where I clearly dominated on the mechanical bull.  I also was crushed in Ping Pong by Chris Goldfarb (PDX INETA), sang a horrible version of Under the Boardwalk with Jonathan Zuck, who it turns out, is a fantastic baritone and while I assumed it was WE who sucked, it was in fact I who sucked. 

Software Legend Juval Lowy's cardboard cutout, that mysteriously absconded (clearly under its own locomotive power) from the Book Mall also put in an appearance on stage at the Influencer's Party.  Who knows where flat Juval will appear next?

Met lots of cool INETA people - User Group leaders from Seattle, Bay.NET, Pakistan and beyond!  Got a picture of me on a giant steer (cause who doesn't want a picture of that) and ate more meat that I really should have. 

Hung out manning the Advanced Web Services booth at Microsoft this afternoon from noon to 3 and answered questions around WSE and WSDL and I pimped my Weds 1:30pm DEV389 - Learning to Love WSDL session shamelessly.

I'm currently proctoring labs down in C141 and hanging with Kent Sharkey and Jas Sandhu.  Kent is teasing me for blogging wirelessly and I'm teasing him for not having updated his blogg in 8 days!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.