在 Win Server 2008 64 位中运行时 ASP.NET 应用程序出现错误
请您帮助我,当我将在 Win Server 2003 32 位运行的应用程序迁移到 Win Server 2008 64 位环境时,我的 ASP.NET 应用程序无法导入 excel 文件。 如何修复这个错误?因为在Win Server 2003 32位下,运行正常。
出现的错误报告是: *System.Runtime.InteropServices.COMException (0x800A03EC):来自 HRESULT 的异常:Microsoft.Office.Interop.Excel.Workbooks.Open 处的 0x800A03EC(字符串文件名、对象 UpdateLinks、对象只读、对象格式、对象密码、对象 WriteResPassword、对象 IgnoreReadOnlyRecommended 、对象原点、对象分隔符、对象可编辑、对象通知、对象转换器、对象AddToMru、Object Local、Object CorruptLoad) at Admin_ImportRisk.CreateTempTable() in C:\inetpub\wwwroot\ERMApproval\Administrator\ImportRisk.aspx.vb:line 66.*
我的应用程序第 66 行中的代码是: oBooks.Open(Server.MapPath("~/App_Data/Risk.xls"))
我尝试了几种方案:
在 DCOM 配置中将网络服务用户添加到 Microsoft Excel 应用程序并设置所使用的应用程序池的标识相同。
在 DCOM 配置的安全性中,将所有多种用户添加到 Microsoft Excel 应用程序和我的计算机中。我也在应用程序的文件夹中添加了多种用户。
使用corflags.exe强制32位应用程序在64位环境中运行
使用regsvr32.exe进行注册将 Microsoft.Office.Interop.Excel.dll 文件添加到 Windows 32 位组件服务。
使用rundll32.exe在32位环境中运行32位Microsoft.Office.Interop.Excel.dll文件
但结果还是一样。 如果您能帮助我,我将非常荣幸^^。 此致, -伊曼纽尔-
May you help me, My ASP.NET application can't import excel file when migrating this application that run in Win Server 2003 32-bit to the Win server 2008 64-bit environment.
How to fix this bug? because in Win Server 2003 32-bit, it runs properly.
the error report that appear is:
*System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad) at Admin_ImportRisk.CreateTempTable() in C:\inetpub\wwwroot\ERMApproval\Administrator\ImportRisk.aspx.vb:line 66.*
The code in line 66 of my application is:
oBooks.Open(Server.MapPath("~/App_Data/Risk.xls"))
I have tried several scenarios:
Added Network Service user to the Microsoft Excel Application in DCOM configuration and set the identity of Application pool that in used to be same.
Added all many kind of user to the Microsoft Excel Application and My computer in security of DCOM configuration. And I have added many kind of user too in the application's folder.
Used corflags.exe to force 32-bit application to run in 64-bit environment
Used regsvr32.exe to register a Microsoft.Office.Interop.Excel.dll file to the windows 32-bit component services.
Used rundll32.exe to run the 32-bit Microsoft.Office.Interop.Excel.dll file in the 32-bit environment
But the result is still the same.
It will be a big honour if you can help me^^.
Best regards,
-imanuel-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的答案是将您的项目编译为仅针对 x86。这是项目设置中的一个设置。因此.net框架在运行时只会生成32位应用程序,而不是默认为64位。这与设置 corflags 没有什么不同,但是如果您有多个程序集,则必须确保对所有程序集都完成了设置。应用程序本身必须仅针对 32 位。
您正在使用 32 位的 COM 组件,而您无法在 64 位应用程序中执行此操作,因此请强制将其设置为 32 位。
您还可以强制 IIS 在 32 位上下文中运行它,如下所述:
http://lostechies.com/gabrielschenker/2009/10/21/force-net-application-to-run-in-32bit-process-on-64bit-os/
另外,确保服务器上没有安装 64 位版本的 Excel,而是安装了 32 位版本。
The simple answer is to compile your project to target x86 only. This is a setting in the project settings. So the .net framework will only generate a 32 bit application at runtime, rather than defaulting to 64 bit. This is no different from setting corflags, however if you have multiple assemblies you ahve to make sure it's done for all of them. The application itself must target only 32 bit.
You're using a COM component that is 32 bit, and you can't do that in a 64 bit application, so force it to be 32 bit.
You can also force IIS to run it in the 32 bit context as documented here:
http://lostechies.com/gabrielschenker/2009/10/21/force-net-application-to-run-in-32bit-process-on-64bit-os/
Also, make sure the 64 bit version of Excel is not installed on the server, but rather the 32 bit version.