问题
I want to add a reference to Microsoft.Office.Interop to a current project but I can only select
but I am able to find them in the GAC
For now I choose to add them by navigating to the path within the GAC
Butt I still have the question, why can it happen that I have them in the GAC (Office 2013 is installed) but cannot find them in Visual Studio 2012 when trying to add a reference?
回答1:
Your assumption that the VS dialog lists assemblies in the GAC is wrong. It lists reference assemblies, they never should be stored in the GAC. The GAC only contains runtime assemblies, they can change anytime when there is a security or bug fix update. Reference assemblies must be stable so you can reproduce the exact same build when you rebuild a project later.
PIAs are obsolete and should not be used anymore. The ones you found are in the old CLR v2 GAC in c:\windows\assembly. They are only meant for projects built with old VS versions, VS2008 and before. The CLR v4 GAC is stored in c:\windows\microsoft.net\assembly. You won't find any Office interop assemblies stored there.
Microsoft does not provide a PIA download for Office 2013 like it did for older Office versions. They have been thoroughly and elegantly replaced by the .NET 4.0/VS2010 "Embed Interop Types" feature. Aka the "No PIA" feature. You must add the reference from the COM tab instead. Like "Microsoft Word 15.0 Object Library" to interop with the 2013 version of Word. Nothing you have to ship along with your program and no need to install PIAs on the user's machine, the Word interop types are embedded into your program when it was built.
来源:https://stackoverflow.com/questions/24529780/vs-2012-does-not-list-microsoft-office-interop-assembly-while-it-can-be-found-in