.NET应用程序中使用excel interop dll的依赖性错误

时间:2013-08-07 16:17:59

标签: .net excel-interop

我在使用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,因此请不要将其纳入您的答案中。谢谢!

1 个答案:

答案 0 :(得分:0)

我最终从我的项目中删除Microsoft.Office.Interop.Excel dll并更改了我的web.config文件中的程序集以匹配C:\Windows\assembly中找到的程序集,现在它可以正常工作。我被this question提示。