C# 在参考列表中找不到 Microsoft.Office.Interop.Word

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16054184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 23:50:52  来源:igfitidea点击:

Can't locate Microsoft.Office.Interop.Word in Reference List

c#visual-studio-2012ms-wordms-officevisual-studio-express

提问by OmniOwl

I was given this solution to a problem I had, since I didn't know how to integrate MS Word with C#: http://www.dotnetperls.com/word

由于我不知道如何将 MS Word 与 C# 集成,我得到了这个解决方案:http: //www.dotnetperls.com/word

I looked into this solution, and I can't locate Microsoft.Office.Interop.Wordin the reference list. I can't find it under COM Objects either. What am I missing? I am using Visual Studio Express 2012.

我查看了这个解决方案,但Microsoft.Office.Interop.Word在参考列表中找不到。我也无法在 COM Objects 下找到它。我错过了什么?我正在使用 Visual Studio Express 2012。

EDIT:

编辑:

The answer to this question is that you HAVE to install MS Office on your computer.

这个问题的答案是您必须在您的计算机上安装 MS Office。

采纳答案by Prabhu Murthy

you might need to install the assemblies separately,if you did not choose to install them during your office installation.

如果您在办公室安装期间没有选择安装这些程序集,则可能需要单独安装这些程序集。

MSDN:

微软:

You must install the Microsoft Office primary interop assemblies (PIAs) in the global assembly cache of your development computer before you can perform certain development tasks. Typically, the PIAs are installed automatically when you install Office on the development computer. However, in some cases you might need to install the PIAs separately.

您必须先在开发计算机的全局程序集缓存中安装 Microsoft Office 主互操作程序集 (PIA),然后才能执行某些开发任务。通常,在开发计算机上安装 Office 时会自动安装 PIA。但是,在某些情况下,您可能需要单独安装 PIA。

More here

更多在这里

回答by Mike Chaliy

You need Microsoft Word xx Object Library.

你需要Microsoft Word xx Object Library.

enter image description here

在此处输入图片说明

回答by Vadois

You can download the Primary Interop Assemblies from here.

您可以从这里下载主互操作程序集。

http://www.microsoft.com/en-us/download/details.aspx?id=3508

http://www.microsoft.com/en-us/download/details.aspx?id=3508

回答by alphaguy

Check if the library (Microsoft.Office.Interop.word) is present in the assembly folder of windows (C:\Windows\assembly) else you can install it from http://www.microsoft.com/en-us/download/details.aspx?id=3508

检查库 (Microsoft.Office.Interop.word) 是否存在于 windows 的程序集文件夹 (C:\Windows\assembly) 中,否则您可以从http://www.microsoft.com/en-us/download安装它/details.aspx?id=3508

Now you just need locate it in your visual studio.

现在你只需要在你的视觉工作室中找到它。

Right click on the consoleApplication(or name of you application) in SolutionExplorer window and

右键单击 SolutionExplorer 窗口中的控制台应用程序(或应用程序名称),然后

Go to Add -> References-> Browse and find C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.word or similar directory. press ok and your can now use the library in your application.

转到添加 -> 引用 -> 浏览并找到 C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.word 或类似目录。按确定,您现在可以在您的应用程序中使用该库。

回答by Roman

You may also use NuGet Package Manager in order to install the reference. Go to Project -> Manage NuGet Packages... Search for "Interop.Word" and install that package.

您还可以使用 NuGet 包管理器来安装参考。转到 Project -> Manage NuGet Packages... 搜索“Interop.Word”并安装该包。

enter image description hereGood thing about it is that you don't need to think about where the dll is located. When another person will check out the solution, NuGet will get all needed packages onto their machine.

在此处输入图片说明它的好处是您无需考虑 dll 所在的位置。当另一个人检查解决方案时,NuGet 会将所有需要的包放到他们的机器上。