Primary Interop Assemblies

Office applications such as Excel and Word are written in unmanaged code.
The only way .NET code can interoperate with the unmanaged Office COM objects is via the Primary Interop Assemblies.
The Microsoft Office Primary Interop assemblies are the interop assemblies that you need to reference and use.
These PIA files are part of Visual Studio and are not included with Office 365, Office 2019 or Office 2016.


Microsoft.Office.Interop

This namespace needs to be referenced in your code

using Excel = Microsoft.Office.Interop.Excel; 
using Word = Microsoft.Office.Interop.Word;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Outlook = Microsoft.Office.Interop.Outlook;

Visual Studio References

When you install Visual Studio, the PIAs are automatically installed into the Visual Studio folder on the C drive.
When you create a new project, references are automatically added to refer to the PIAs on the C drive.
Can be added as a COM Reference.


Embedded PIAs

Visual Studio 2010 (C# v4.0) provided the ability to Embed Interop Types


Interop Assemblies

The primary interop assemblies are the corresponding runtime callable wrappers for the Microsoft Office applications.
When you are adding references to PIAs from within your project you should use the .NET tab.
It is possible to create your own wrappers for COM Object Models using tlbimp.exe.
An interop assembly is a managed .NET equivalent of a COM type library.
An Interop Assembly that is distributed by the owner of the original COM server is called a primary interop assembly (PIA).
Primary Interop Assemblies are always digitally signed by the publisher of the original unmanaged assembly.


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext