Project 2003 and .NET COM Primary Interop Assemblies - c#

I am creating an app in C# using the .NET COM Primary Interop Assemblies. I was wondering if this will be able to open and read files from both Project 2003 and Project 2007. Also, does Project have to be installe don the computer that is running this app?

That's Yes and Yes. You'll have to use the 2003 PIA, Office versions beyond this are backwards compatible with older COM interface specifications. But of course you won't be able to use 2007 specific features. You can't do anything with Project if it isn't installed on the machine. Project 2003 isn't likely to be able to read Project 2007 files unless the file was saved in 2003 format. No problem the other way around.

Related

How to make Windows forms app to support Older versions of MS Office?

I need to develop a windows app program. I have Office 2013 in my Machine. And I need to develop the app which supports Office 2013 User machine also. How to do reference dll for it?
I expect that I will develop using Office 2013 and it should supports(the app should work) on Office 2010 also
I have made the app with excel 14.0 reference file. So that if a machine have excel 2010, then the app couldn't open on that
Things go the other way around with Office!
To support all versions of Office back to 2010, you have to develop and maintain your WinForms application with Office 2010, that is the oldest version of Office that you want to support. Whenever you deploy your application on a machine that has Office 2010 or a more recent version, it will work. But it will fail with older versions such as 2007 and 2003.
This design makes sense since one cannot expect that a workook developed with say, Excel 2016, can be run by Excel 2010 without error. The 2016 workbook may use features that did not exist in 2010.

How can i add Microsoft.Office.Interop.Word to setup file?

I'm creating a WPF application in Visual Studio 2015 that uses Microsoft.Office.Interop.Word for create Word document.When I create setup file for my project and run it in my PC everything is good but when I install and run it on a different PC it doesn't work.
How can i add Microsoft.Office.Interop.Word to setup file?
This interop is registered in the GAC after office / msword install on the PC. (which means you don't need to distribute the dll)
Check here for more info about PIAs. It states the following:
To perform certain development tasks, the PIAs must be installed and
registered in the global assembly cache on the development computer.
Typically, the PIAs are installed automatically when you install
Office on the development computer. For more information, see
Configuring a Computer to Develop Office Solutions.
The Office PIAs are not required on end-user computers to run Office
solutions. For more information, see Designing and Creating Office
Solutions.
Best option is to use some alternative of MsWord (check comments) or you can check on startup in the registry for the office install if available and if not you need to notify the user which functionalities won't work (or disallow usage of the application if more appropriate).
You don't need to explicitly include PIA as part of your set up (from C#4 onward)
In your local - right click assembly properties and make Embed Interop Type to true. Relevant types required to communicate to office com type will get embedded to your assembly.

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 ?
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).
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.
Your question really has two parts:
What does a developer need to develop an application that makes use of Office components?
What does an end user need to run that application?
On MSDN, the article Office Solutions Development Overview (Visual Studio 2013) provides concise guidance for these questions. From the section "Automating Office Applications by Using Primary Interop Assemblies":
You must have the Office PIAs installed and registered in the global
assembly cache on your development computer to perform most
development tasks. For more information, see Configuring a Computer
to Develop Office Solutions. The Office PIAs are not required on
end-user computers to run Office solutions. For more information, see
Designing and Creating Office Solutions.
The first article makes it clear that the developer must install Microsoft Office:
To create add-ins and customizations for Microsoft Office, install a
supported version of Visual Studio, the .NET Framework, and Microsoft
Office.
And from the latter article in the section "Understanding When the Office PIAs Are Required on End User Computers":
By default, Office primary interop assemblies (PIAs) do not need to be
installed on end user computers if the Embed Interop Types
property of each Office PIA reference in the project is set to
True, which is the default value. In this scenario, 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,
see Type Equivalence and Embedded Interop Types.

How to create an Excel application using PIA (2010, version 14.0) and target machine doesn't have MS Office client installed on it

I'm facing one issue, actually I need to create one application in C# using VS2012, .Net framework 4.5 which reads excel and do some operation, but the issue is target machine doesn't have MS Office client installed on it.
And one restriction is I can't use the other open assemblies like Open XML etc. I have to only use the 2010 PIA.
It'll be great if someone can explain me how can implement this?
This can not be possible without installing MS Office on server. To use PIA you have to install the MS Office on server. Otherwise, if you doesn't want to install MS Office on server, it's better to use Open XML.

deploy a windows form application which links to two excel files created on visual studio 2010 on another system

I have created a windows form application in visual studio 2010 which has 4 forms in it. 3 of these files are connected to 2 different excel files. Now, I want this application to run on another system which has the same excel files. I have just made the application but I am clueless on what to do in order to run it as an application on the other system.
I understand that you are relying on "Interop" to communicate with Excel. In that case, you have to make sure that Microsoft Office is installed on the target computer. In order to avoid problems, confirm that the version is equal to the one you used to create the application.
If the target version of Office is 2007 or older, the Redistributable Primary Interop Assemblies have to be installed on the given computer (link to the 2007 version).

Categories

Resources