Today, I wrote a small program to use. Net to operate the Office template file and generate the expected Word file. The development environment runs normally and can be put on another machine, which is not easy to use. The system prompts that com… cannot be found ....
Confirm that the Office is installed on the target machine, and the version is the same as the development environment. The only difference is that vs is not installed on the target machine. refactor the program on the target machine and immediately find that Microsoft cannot be found. office. interOP. word. DLL.
Solve the problem after installing office Pia. Later, it was found that the target machine was installed with the so-called Lite version of Office, for a clear reason.
Office Pia is actually supported by office. NET programming. After installation, the office library will appear in the com list of Vs, rather than in the. NET component.
References:
Visual Studio Tools for the Microsoft Office System
Office primary InterOP assemblies
When you create a new visual Studio Tools for Office Project, a reference to the correct primary InterOP assembly (PIA) is added to your project automatically if the assembly is installed in the Windows Global Assembly Cache (GAC ). the Microsoft Office primary InterOP assemblies are installed in the Global Assembly Cache during a complete installation.
For more information about primary InterOP assemblies, see primary InterOP assemblies and the msdn article "primary InterOP assemblies (PIAs)" (http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/dndotnet/html/whypriinterop. asp ).
Applications that do not have projects in Visual Studio Tools for office
For Microsoft Office applications that do not have projects in Visual Studio Tools for office, you must add a reference to the appropriate application or component to your project manually. adding a reference to the component references the primary InterOP assembly, if the Assembly is installed in the global assembly cache. office applications and components are accessible fromComTab OfAdd referenceDialog box.
If the primary InterOP assembly is not installed in the Global Assembly Cache, Visual Studio generates an InterOP assembly for the project that might not work fully in all cases. for more information, see troubleshooting in office at run time.
Note
Some assemblies are added to a project automatically when an assembly that references them is added. for example, references to the assemblies office. DLL and Microsoft. VBE. interOP. DLL are added automatically when you add a reference to the Word, Excel, outlook, Microsoft forms, or graph assemblies.
For more information about installing office primary InterOP assemblies, see How to: Install office primary InterOP assemblies. for more information about adding references, see How to: add and remove references in Visual Studio (C #, J #).
Available assemblies for Microsoft Office 2003
The following table shows primary InterOP assemblies that are available to install with Microsoft Office 2003.
Office application or component
Primary InterOP Assembly name
Microsoft Access 11.0 Object Library
Microsoft. Office. InterOP. Access. dll
Microsoft Excel 11.0 Object Library
Microsoft. Office. InterOP. Excel. dll
Microsoft Frontpage 6.0 web object reference library
Microsoft. Office. InterOP. FrontPage. dll
Microsoft Frontpage 6.0 Page Object Reference Library
Microsoft. Office. InterOP. frontpageeditor. dll
Microsoft Graph 11.0 Object Library (used by PowerPoint, access, and word for graphs)
Microsoft. Office. InterOP. graph. dll
Microsoft Outlook 11.0 Object Library
Microsoft. Office. InterOP. Outlook. dll
Microsoft Outlook View Control (can be used in web pages and applications to access your inbox)
Microsoft. Office. InterOP. outlookviewctl. dll
Microsoft Office Web Components 11.0 (spreadsheet, graph, and dynamic table for Web Pages)
Microsoft. Office. InterOP. owc11.dll
Microsoft PowerPoint 11.0 Object Library
Microsoft. Office. InterOP. PowerPoint. dll
Microsoft Publisher 11.0 Object Library
Microsoft. Office. InterOP. publisher. dll
Microsoft Smart Tags 2.0 Type Library
Microsoft. Office. InterOP. smarttag. dll
Microsoft Word 11.0 Object Library
Microsoft. Office. InterOP. Word. dll
Microsoft Visual Basic for Applications extensibility 5.3
Microsoft. VBE. InterOP. dll
Microsoft forms 2.0 Object Library (programmable controls that can be used in applications)
Microsoft. VBE. InterOP. Forms. dll
Microsoft Office 11.0 Object Library (Office shared functionality)
Office. dll
Available assemblies in the 2007 Microsoft Office System
The following table shows primary InterOP assemblies that are available to install with the 2007 Microsoft Office System.
Office application or component
Primary InterOP Assembly name
Microsoft Access 12.0 Object Library
Microsoft. Office. InterOP. Access. dll
Microsoft Office 2007 Access Database Engine Object Library
Microsoft. Office. InterOP. Access. Dao. dll
Microsoft Excel 12.0 Object Library
Microsoft. Office. InterOP. Excel. dll
Microsoft Graph 12.0 Object Library (used by PowerPoint, access, and word for graphs)
Microsoft. Office. InterOP. graph. dll
Microsoft infopath 2.0 Type Library
Microsoft. Office. InterOP. infopath. dll
Microsoft infopath XML InterOP assembly
Microsoft. Office. InterOP. infopath. xml. dll
Microsoft Outlook 12.0 Object Library
Microsoft. Office. InterOP. Outlook. dll
Microsoft Office Outlook View Control (can be used in web pages and applications to access your inbox)
Microsoft. Office. InterOP. outlookviewctl. dll
Microsoft PowerPoint 12.0 Object Library
Microsoft. Office. InterOP. PowerPoint. dll
Microsoft Publisher 12.0 Object Library
Microsoft. Office. InterOP. publisher. dll
Microsoft foreign pointdesigner 12.0 web object reference library
Microsoft. Office. InterOP. sharepointdesigner. dll
Microsoft foreign pointdesigner 12.0 Page Object Reference Library
Microsoft. Office. InterOP. sharepointdesignerpage. dll
Microsoft Smart Tags 2.0 Type Library
Microsoft. Office. InterOP. smarttag. dll
Microsoft Visio 12.0 Type Library
Microsoft. Office. InterOP. Visio. dll
Microsoft Visio 12.0 save as Web Type Library
Microsoft. Office. InterOP. Visio. saveasweb. dll
Microsoft Visio 12.0 Drawing Control Type Library
Microsoft. Office. InterOP. visocx. dll
Microsoft Word 12.0 Object Library
Microsoft. Office. InterOP. Word. dll
Microsoft Visual Basic for Applications extensibility 5.3
Microsoft. VBE. InterOP. dll
Microsoft Office 12.0 Object Library (Office shared functionality)
Office. dll
Binding redirect assembly for Microsoft Access Object Library
Policy.11.0.microsoft. Office. InterOP. Access. dll
Binding redirect assembly for Microsoft Excel Object Library
Policy.11.0.microsoft. Office. InterOP. Excel. dll
Binding redirect assembly for Microsoft Graph Object Library
Policy.11.0.microsoft. Office. InterOP. graph. dll
Binding redirect assembly for Microsoft infopath Type Library
Policy.11.0.microsoft. Office. InterOP. infopath. dll
Binding redirect assembly for Microsoft infopath XML InterOP assembly
Policy.11.0.microsoft. Office. InterOP. infopath. xml. dll
Binding redirect assembly for Microsoft Outlook Object Library
Policy.11.0.microsoft. Office. InterOP. Outlook. dll
Binding redirect assembly for Microsoft Outlook View Control
Policy.11.0.microsoft. Office. InterOP. outlookviewctl. dll
Binding redirect assembly for Microsoft PowerPoint Object Library
Policy.11.0.microsoft. Office. InterOP. PowerPoint. dll
Binding redirect assembly for Microsoft Publisher Object Library
Policy.11.0.microsoft. Office. InterOP. publisher. dll
Binding redirect assembly for Microsoft Smart Tags Type Library
Policy.11.0.microsoft. Office. InterOP. smarttag. dll
Microsoft Visio Type Library
Policy.11.0.microsoft. Office. InterOP. Visio. dll
Binding redirect assembly for Microsoft Visio save as Web Type Library
Policy.11.0.microsoft. Office. InterOP. Visio. saveasweb. dll
Binding redirect assembly for Microsoft Visio Drawing Control Type Library
Policy.11.0.microsoft. Office. InterOP. visocx. dll
Binding redirect assembly for Microsoft Word Object Library
Policy.11.0.microsoft. Office. InterOP. Word. dll
Binding redirect assembly for Microsoft Visual Basic for Applications extensibility 5.3
Policy.11.0.microsoft. VBE. InterOP. dll
Binding redirect assembly for Microsoft Office Object Library
Yy.11.0.office. dll
Note
The binding redirect assemblies help make sure that the 2007 Microsoft Office version of the primary InterOP assemblies are loaded at run time. when a Visual Studio Tools for office solution that references a Microsoft Office 2003 primary InterOP Assembly runs on a computer that has the 2007 Microsoft Office version of the same primary InterOP assembly, the binding redirect Assembly instructs. net Framework runtime to load the 2007 Microsoft Office version of the primary InterOP assembly. for more information, see Assembly Binding redirection. from: http://msdn.microsoft.com/en-us/library/15s06t57 (vs.80 ). aspx
References:
How to: use the main interoperability assemblyOfficeApplications
When creating a visual Studio Tools for office project in Visual Studio, if you have installed the correct primary interoperability assembly (PIA) in the Global Assembly Cache (GAC) of your computer ), the reference to the Assembly is automatically added to the project. To use managed code to automate functions of other Microsoft Office applications, you must manually add references to the corresponding components.
Note: |
The displayed dialog box and menu command may be different from the description in "help", depending on your current settings or version. To change the settings, select "Import and Export Settings" from the "Tools" menu ". For more information, see Visual Studio settings. |
Add reference to the main interoperability assembly
1. Open the Visual Studio Tools for office project and select the project name in Solution Explorer.
2. Open the "project" menu and click "add reference ".
3. On the "com" tab, select the required component from the "component name" list. For a list of Microsoft Office main interoperability assembly and corresponding component names, see Office main interoperability assembly.
4. Click OK ".
The component name appears in the reference folder of Solution Explorer.
If the master interoperability assembly is not installed in the Global Assembly Cache or cannot be accessed, Visual Studio generates an interoperability assembly for the project, but the Assembly may not work in all circumstances. In this case, Visual Studio creates the assembly in the folder of the project rather than in the global assembly cache. You can check the path property of the Assembly in the "properties" Window of Visual Studio to find the location of the Assembly. For more information, see "unable to initialize assembly" in the troubleshooting section of the Office runtime ".
See
Task
How to: Install the main office interoperability assembly
How to: automate office applications by using Master interoperability assembly
Other resources
Program Office applications
Automate applications using the office Object Model