简体   繁体   English

找不到Microsoft.Office.Interop Visual Studio

[英]Cannot find Microsoft.Office.Interop Visual Studio

I need to develop an application which will has the capability to send emails using C# with visual studio. 我需要开发一个能够使用Visual Studio使用C#发送电子邮件的应用程序。 The app will be able to use templates for mail, and a lot of things, but I have a problem. 该应用程序将能够使用模板进行邮件和很多事情,但我有一个问题。

I cannot find any Office.Interop references when I try to add them, which is mean I cannot work with Outlook. 当我尝试添加它时,我找不到任何Office.Interop引用,这意味着我无法使用Outlook。 Office is installed on my computer, but i also try to install the PIA from this link http://www.microsoft.com/en-us/download/details.aspx?id=3508 but it didn't change anything (when I launch the MSI it stops without a word, I don't know if it's part of the problem). Office安装在我的计算机上,但我也尝试通过此链接安装PIA http://www.microsoft.com/en-us/download/details.aspx?id=3508但它没有改变任何东西(当我启动MSI它一言不发,我不知道它是否是问题的一部分)。

I use VS 2013 express is it part of its limitation? 我使用VS 2013快递是它的一部分限制吗?

Look for them under COM when trying to add the references. 在尝试添加引用时在COM下查找它们。 You should find the reference below, and possibly Microsoft Outlook 15.0 Object Library, if you need that. 如果需要,您应该找到下面的参考,可能还有Microsoft Outlook 15.0对象库。 There are similar libraries for Word, Excel, etc.: Word,Excel等有类似的库:

在此输入图像描述

Update: The Object Library should contain the Interop stuff. 更新:对象库应包含Interop内容。 Try to add this to a source file, and see if it does not find what you need: 尝试将其添加到源文件中,看看它是否找不到您需要的内容:

using Microsoft.Office.Interop.Outlook;

在此输入图像描述

如果您使用的是Visual Studio 2015并且遇到此问题,则可以在此处安装VS Office的MS Office Developer Tools。

I forgot to select Microsoft Office Developer Tools for installation initially. 我最初忘了选择Microsoft Office Developer Tools进行安装。 In my case Visual Studio Professional 2013 and also 2015. 在我的案例中,Visual Studio Professional 2013和2015。

在此输入图像描述

With Visual Studio 2015 I have activated it with the following steps. 使用Visual Studio 2015,我已通过以下步骤激活它。

  1. Programs and Features --> Select Visual Studio > Change 程序和功能 - >选择Visual Studio>更改
  2. Choose Modify 选择修改
  3. Windows and Webdevelopment --> Tick "Microsoft Office Developer Tools" Windows和Webdevelopment - > 勾选“Microsoft Office Developer Tools”
  4. Start Update 开始升级

It should work now. 它现在应该工作。

You can find it at link: 你可以在链接找到它:

C:\\Windows\\assembly\\GAC_MSIL\\Microsoft.Office.Interop.Word\\15.0.0.0__71e9bce111e9429c\\Microsoft.Office.Interop.Word.dll C:\\ WINDOWS \\装配\\ GAC_MSIL \\的Microsoft.Office.Interop.Word \\ 15.0.0.0__71e9bce111e9429c \\ Microsoft.Office.Interop.Word.dll

Browse it then add references 浏览它然后添加引用

If you have installed latest Visual studio and want to To locate library of Microsoft.Office.Interop.Outlook or any other Microsoft.Office.Interop library then you should look into below 2 folders: 如果您已经安装了最新的Visual Studio,并希望要查找的图书馆Microsoft.Office.Interop.Outlook或任何其他Microsoft.Office.Interop库,那么你应该看看下面的2个文件夹:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office14

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15

Please note that folder could be C:\\Program Files\\ 请注意,该文件夹可能是C:\\Program Files\\

I think you need to run that .msi to install the dlls. 我认为你需要运行.msi来安装dll。 After I ran that .msi I can go to (VS 2012) Add References > Assemblies > Extensions and all of the Microsoft.Office.Interop dlls are there. 运行.msi后,我可以去(VS 2012)添加引用>程序集>扩展,并且所有的Microsoft.Office.Interop dll都在那里。

On my computer the dlls are found in "c:\\Program Files(x86)\\Microsoft Visual Studio 12.0\\Visual Studio Tools for Office\\PIA" so you could check in a similar/equivalent directory on yours just to make sure they're not there? 在我的计算机上,dll可以在“c:\\ Program Files(x86)\\ Microsoft Visual Studio 12.0 \\ Visual Studio Tools for Office \\ PIA”中找到,因此您可以检查您的类似/等效目录,以确保它们是不在那里?

You need to install Visual Studio Tools for Office Runtime Redistributable: 您需要为Office Runtime Redistributable安装Visual Studio工具:

http://msdn.microsoft.com/en-us/library/ms178739.aspx http://msdn.microsoft.com/en-us/library/ms178739.aspx

I had the same issue with Visual Studio Community 2013, I fixed it downloading and installing the latest update of Office Developer Tools for Visual Studio 2013. Now I am able to see the whole Microsoft.Office.Interop.* list when I go to 我在Visual Studio Community 2013中遇到了同样的问题,我修复了下载并安装Visual Studio 2013的Office Developer Tools的最新更新。现在我可以看到整个Microsoft.Office.Interop。*列表

Add References > Assemblies > Extensions 添加引用>装配>扩展

you can download it from here: 你可以在这里下载:

https://www.visualstudio.com/en-us/news/vs2013-update4-rtm-vs.aspx#Office https://www.visualstudio.com/en-us/news/vs2013-update4-rtm-vs.aspx#Office
http://aka.ms/OfficeDevToolsForVS2013 http://aka.ms/OfficeDevToolsForVS2013

Just doing like @Kjartan. 就像@Kjartan一样。

Steps are as follows: 步骤如下:

  1. Right click your C# project name in Visual Studio's "Solution Explorer"; 在Visual Studio的“解决方案资源管理器”中右键单击您的C#项目名称;

  2. Then, select "add -> Reference -> COM -> Type Libraries " in order; 然后,依次选择“添加 - >参考 - > COM - >类型库”;

  3. Find the "Microsoft Office 16.0 Object Library", and add it to reference (Note: the version number may vary with the OFFICE you have installed); 找到“Microsoft Office 16.0对象库”,并将其添加到引用(注意:版本号可能因您安装的OFFICE而异);

  4. After doing this, you will see "Microsoft.Office.Interop.Word" under the "Reference" item in your project. 执行此操作后,您将在项目的“参考”项下看到“Microsoft.Office.Interop.Word”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM