Question

This concept is new to me, and a colleague suggested it. Sadly, I had no idea what he was talking about. Can someone enlighten me?

Was it helpful?

Solution

You can find plenty of information about it here.

In a nutshell, a PIA is a signed interop assembly that provides the "official" definition of types in a COM library from the publisher of the COM library.

As to the benefits, the posted article sums it up pretty good:

PIAs are important because they provide unique type identity. The PIA distinguishes the official type definitions from counterfeit definitions provided by other interop assemblies. Having a single type identity ensures type compatibility between applications that share the types defined in the PIA. Because the PIA is signed by its publisher and labeled with the PrimaryInteropAssembly attribute, it can be differentiated from other interop assemblies that define the same types.

OTHER TIPS

A primary interop assembly will wrap the COM interfaces into .NET compatible types. It doesn't give you the granular control that manually invoking the methods does, but it's close enough.

Without a PIA:

object _comObject;
Type _comObjectType;
_comObjectType = Type.GetTypeFromProgID("MyCompany.MyApplication.MyObject", true);
_comObject = Activator.CreateInstance(_comObjectType);

string name = (string)_comObjectType.InvokeMember("GetCustomerName", BindingFlags.InvokeMethod, null, _comObject, , new object [] { _customerId });

With a PIA:

MyCompany.MyApplication.MyObject obj = new MyObject();
string name = obj.GetCustomerName(_customerId);

Simply saying through an example,if you want to develop an application resembles like any other office tools(MS word,visio...) with extended functionality, you can use the functionality of office tools in your project using PIA.In my class diagram drawing app,use visio panel for class diagram creation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top