部署Excel库时出现ASP.NET IIS错误

时间:2015-05-28 09:16:18

标签: asp.net iis deployment web-config

我在Windows Server 2008上的IIS 7.5中部署asp.net应用程序时遇到错误。我引用了Excel 2007,它也存在于Windows Server 2008中。

这是我的web.config代码

<system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

        <add assembly="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
        <add assembly="Microsoft.Office.Tools.Excel.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>
    </compilation>

获取以下错误消息

Server Error in '/dev' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'Microsoft.Office.Tools.Excel.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Source Error:


An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.


Source File: C:\inetpub\wwwroot\dev\web.config    Line: 32

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Office.Tools.Excel.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.

1 个答案:

答案 0 :(得分:0)

尝试这个解决方案。

1.Open Visual studio  -> visual Studio tools -> Visual studio command prompt

2.Run following command 
C:\Windows\system32>gacutil /i c:\Microsoft.VisualStudio.Tools.Office.Runtime.v9.0 (Location of dll)

3. Restart your computer and try.