Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Primary Interop Assemblies ( PIA ) require Microsoft Office to be installed in the machine to work

Does Primary Interop Assemblies ( PIA ) require Microsoft Office to be installed in the machine to work ?

I have gone through so many confusing post/sites and unable arrivie at a conclusion.

I have a machine where office is not installed and I am using VS2010 . As Microsoft.Office.Interop.Excel assembly was not avaialble in COM section in referance . I add it through thought .Net section in referances . Still it throws the below error .

Retrieving the COM class factory for component with CLSID failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

This is statement from Mircosoft website , The Office PIAs are not required on end-user computers to run Office solutions . What does this mean exactly ?

Does it mean without Office installation we can work with interop assemblies ?

If not why we require PIA when office needs to be installed to get things work ?

like image 968
Midhun Murali Avatar asked Jun 30 '15 08:06

Midhun Murali


2 Answers

This is statement from Mircosoft website , The Office PIAs are not required on end-user computers to run Office solutions . What does this mean exactly ?

That's not the current quote I find. The one I find is:

The PIAs must also be installed on end-user computers to run Office solutions that target the .NET Framework 3.5. However, the Office PIAs are not required on end-user computers to run Office solutions that target the .NET Framework 4. For more information, see Designing and Creating Office Solutions. (https://msdn.microsoft.com/en-us/library/vstudio/hy7c6z9k(v=vs.100).aspx)

It means (for net 4+) that when you create an Office Solution in VS usint PIAs, you do not need to install those PIAs on the target computer to be able to run the solution. (the reason is because, if you've targeted Net4, if the Embed Interop Types property of each Office PIA reference in the project is set to True (this is the default value), the type information for the PIA types that are used by your solution is embedded into the solution assembly when you build the project. At run time, the embedded type information is used instead of the PIAs to call into the Office application's COM-based object model. For more information about how types from PIAs are embedded into your solution (https://msdn.microsoft.com/en-us/library/vstudio/3295w01c(v=vs.100).aspx)

For example: I want to write a program in VB to doSomething on an XLSX sheet.

I have to install Excel, PIA, and VS on my development machine or I will not be able to write it.

Once this program is finished, I want Bob in accounting to run it. So I publish the program and it gets installed on Bob's machine. Bob will not need to have installed PIAs on his local machine to run the program. He will need office.

Does it mean without Office installation we can work with interop assemblies ?

The other way around. It means, with Net 4+ applications using PIA (EIT), your application can work without PIAs installed on the client machine (the needed pieces will be part of your deployment).

like image 136
JerryLove Avatar answered Oct 18 '22 20:10

JerryLove


Does Primary Interop Assemblies ( PIA ) require Microsoft Office to be installed in the machine to work ?

Yes.

The PIA are simply assemblies that allow you to call the Office COM object model from .NET. The COM objects which are hosted by the Office applications still need to be present for this to work. The Class not registered error you get is because the COM object is missing on the computer. To fix that you need to install the version of Office your application is designed to work with.

like image 29
Martin Liversage Avatar answered Oct 18 '22 20:10

Martin Liversage