0

我在使用 microsoft excel 互操作库的本地计算机上运行 .NET 应用程序。它一直在工作,直到今天我删除了库,然后将其添加回项目中。直到几周前,我一直在使用 Excel 的试用版来运行这个应用程序,甚至在我的试用期到期后它也能正常工作。但我担心现在由于试用期已过,我从项目中删除了库并将其放回原处,这就是导致此错误的原因。我在这里正确吗?重新安装excel是否应该解决这个问题?

这是我尝试运行应用程序时遇到的错误:

Parser Error Message: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

和日志:

=== Pre-bind state information ===
LOG: User = Aaron-PC\Aaron
LOG: DisplayName = Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Aaron/Documents/Visual Studio 2012/WebSites/WebSite1/
LOG: Initial PrivatePath = C:\Users\Aaron\Documents\Visual Studio 2012\WebSites\WebSite1\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Aaron\Documents\Visual Studio 2012\WebSites\WebSite1\web.config
LOG: Using host configuration file: C:\Users\Aaron\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/Aaron/AppData/Local/Temp/Temporary ASP.NET Files/root/fd4ebee9/714ba73d/Microsoft.Office.Interop.Excel.DLL.
LOG: Attempting download of new URL file:///C:/Users/Aaron/AppData/Local/Temp/Temporary ASP.NET Files/root/fd4ebee9/714ba73d/Microsoft.Office.Interop.Excel/Microsoft.Office.Interop.Excel.DLL.
LOG: Attempting download of new URL file:///C:/Users/Aaron/Documents/Visual Studio 2012/WebSites/WebSite1/bin/Microsoft.Office.Interop.Excel.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

此外,我知道 Microsoft 不建议在 .NET 应用程序中使用 excel,因此请不要将其纳入您的答案。谢谢!

4

1 回答 1

0

我最终Microsoft.Office.Interop.Excel从我的项目中删除了 dll 并更改了我的 web.config 文件中的程序集以匹配在其中找到的程序集C:\Windows\assembly,现在它可以工作了。我被这个问题告知了。

于 2013-08-07T19:27:33.350 回答