Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone explain the benefits of using a Primary Interop Assembly in .Net?

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?

like image 862
Kilhoffer Avatar asked Oct 15 '08 13:10

Kilhoffer


People also ask

What is .NET interop assembly?

Interop assemblies are . NET Framework assemblies that bridge between managed and unmanaged code, mapping COM object members to equivalent . NET Framework managed members. Interop assemblies created by Visual Basic . NET handle many of the details of working with COM objects, such as interoperability marshalling.

Where are primary interop assemblies installed?

Primary interop assemblies in the program files directory The PIAs are automatically added to a location in the file system, outside of the global assembly cache, while you install Visual Studio.

Do we need to register Interop DLL?

Although it is not necessary to register primary interop assemblies unless you plan to use Visual Studio, registration provides two advantages: A registered primary interop assembly is clearly marked under the registry key of the original type library.

What is Microsoft Interop?

Microsoft Office Interop (Excel Automation) is an option when creating/reading Excel files (XLS, XLSX, CSV) from C# or VB.NET application, but it has many drawbacks.


2 Answers

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.

like image 188
Gerald Avatar answered Oct 02 '22 19:10

Gerald


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.

like image 32
Richardson V Johnson Avatar answered Oct 02 '22 20:10

Richardson V Johnson