简体   繁体   中英

Can't find Interop dll in project

I'm developing a C# project using Microsoft Word 2007. I add to my project a reference to the Word component. After compiling I can't find Interop dll in the bin. Where can I find Interop dll? I need to copy it.

In the Word Component, expand your project references, find the Interop dll, highlight it, and in the properties window enable Copy Local. After compiling again, you should now see the dll in your output directory.

In a normal configuration, Office has installed the dll (PIA = Primary Interop Assembly) in the GAC. So there's no need for you to distribute it with your project.

With Office 2007 there's always the caveat that the PIAs are not installed by default, so the user's machine might not have them in the GAC. For this reason, Microsoft has provided a redistributable as a download. Your installation can check for the presence of the PIA(s) used in your project and install them (same as you would the .NET Framework).

It's possible to create your own IA using tlbimp.exe ( https://msdn.microsoft.com/en-us/library/tw4zwhbe(v=vs.110).aspx ) and there are circumstances when you might want to do so. In this case, you would distribute the dll with your project.

Hans mentions the "Embed interop types" option for more recent versions of the .NET Framework. This can be useful, but thorough testing is necessary as this option sometimes gives "unexpected results" (embeds the wrong or incomplete information from the PIA).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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