Excel的互操作库与ASP.NET不兼容? [英] Excel interop libraries incompatible with ASP.NET?

查看:80
本文介绍了Excel的互操作库与ASP.NET不兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Excel互操作图书馆阅读并插入到一个Excel US preadsheet一个简单的Web应用程序。我以我的尽职调查,以确保我不要用两个点并确保所有的COM对象引用是通过使用对Marshal.ReleaseComObject()和<$ C发布$ C> GC.Collect的(),但仍有我的服务器上运行的EXCEL.EXE进程。

I have a simple web application which uses the Excel Interop libraries to read and insert into an Excel spreadsheet. I'm taking my due diligence to ensure that I don't use two dots and to ensure that all COM object references are released by using Marshal.ReleaseComObject() and GC.Collect(), but there is still an EXCEL.EXE process running on my server.

我创建了一个Windows窗体应用程序使用同一个对象释放过程,在我的ASP.NET应用程序,并成功结束的过程。有没有涉及使用互操作的库与ASP.NET,我已经忽略了什么?

I've created a Windows Forms application that uses the same object releasing process as in my ASP.NET app, and it ends the process successfully. Is there something involved with using the Interop libraries with ASP.NET that I've overlooked?

编辑:在黑暗中,也许需要的权限在服务器上的特定的方式来建立一个镜头?我使用&LT;身份冒充=真/方式&gt; 在我的web.config文件,我的服务器上的本地管理员

As a shot in the dark, maybe permissions need to be set up in a specific way on the server? I'm using <identity impersonate="true"/> in my web.config file and am a local administrator on the server.

推荐答案

我不知道这正是一个答案,但我已经做了很多ASP.NET和Excel互操作,并可以为您提供一些我的观察/指针

I'm not sure this is exactly an answer but I have worked a lot with ASP.NET and Excel Interop and can offer you some of my observations / pointers.

如果您使用任务管理器,你可以看到哪些用户仍然在运行过程EXCEL.EXE - 这是最有可能的应用程序池身份

If you use Task Manager you can see which user is still running EXCEL.EXE process - it's most likely the AppPool Identity.

从经验看,当应用程序池回收,这将关闭Excel。

From experience when the app pool recycles this will close Excel.

您可能也注意到了,如果你再次运行脚本第二Excel打开和将关闭!

Also you may notice that if you run your script again a second Excel opens and will close!

有关参考,这是我关闭Excel code:

For reference, here is my Close Excel code:

xl.Quit();
Marshal.ReleaseComObject(xl);
xl = null;
GC.Collect();

这篇关于Excel的互操作库与ASP.NET不兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆