excel进程无法正常终止 [英] excel process not terminating properly

查看:114
本文介绍了excel进程无法正常终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我正在努力释放com对象。我

已将问题隔离到下面的代码中。对象被释放并且

过程结束,直到我使用int k = sheet.Count;然后该过程不会结束。所以我觉得

对这里出现的问题充满信心。看来另一个参考是

需要关闭。谁能告诉我怎么做

这个? :)

谢谢


Excel.Workbook工作簿=

(Excel.Workbook)excelapplication.ActiveWorkbook;

Excel.Sheets sheet = workbook.Worksheets;


//这里有问题

int k = sheet.Count;


System.Runtime.InteropServices.Marshal.ReleaseComO bject(sheet);

sheet = null;

System.Runtime.InteropServices.Marshal.ReleaseComO bject (工作簿);

工作簿= null;

hello all you gurus. I am struggling with releasing com objects. I
have isolated the problem to the code below. Objects are released and
the process ends until I
use "int k = sheet.Count;" Then the process does not end. So I feel
confident the problem occurrs here. It appears another reference is
created that needs to be closed. Can anyone tell me how to do
this? :)
Thank you

Excel.Workbook workbook =
(Excel.Workbook)excelapplication.ActiveWorkbook;
Excel.Sheets sheet = workbook.Worksheets;

// problem here
int k = sheet.Count;

System.Runtime.InteropServices.Marshal.ReleaseComO bject(sheet);
sheet = null;
System.Runtime.InteropServices.Marshal.ReleaseComO bject(workbook);
workbook = null;

推荐答案

尝试在调用ReleaseCOMObject之前添加以下内容在他们身上:


sheet = null;

workbook = null;


< ch **** ****** @ hotmail.com写信息

新闻:11 ********************** @ y80g2000hsf.googlegr oups .com ...
Try adding the following just BEFORE your call ReleaseCOMObject on them:

sheet = null;
workbook = null;

<ch**********@hotmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...

你好你所有的大师。我正在努力释放com对象。我

已将问题隔离到下面的代码中。对象被释放并且

过程结束,直到我使用int k = sheet.Count;然后该过程不会结束。所以我觉得

对这里出现的问题充满信心。看来另一个参考是

需要关闭。谁能告诉我怎么做

这个? :)

谢谢


Excel.Workbook工作簿=

(Excel.Workbook)excelapplication.ActiveWorkbook;

Excel.Sheets sheet = workbook.Worksheets;


//这里有问题

int k = sheet.Count;


System.Runtime.InteropServices.Marshal.ReleaseComO bject(sheet);

sheet = null;

System.Runtime.InteropServices.Marshal.ReleaseComO bject (工作簿);

workbook = null;
hello all you gurus. I am struggling with releasing com objects. I
have isolated the problem to the code below. Objects are released and
the process ends until I
use "int k = sheet.Count;" Then the process does not end. So I feel
confident the problem occurrs here. It appears another reference is
created that needs to be closed. Can anyone tell me how to do
this? :)
Thank you

Excel.Workbook workbook =
(Excel.Workbook)excelapplication.ActiveWorkbook;
Excel.Sheets sheet = workbook.Worksheets;

// problem here
int k = sheet.Count;

System.Runtime.InteropServices.Marshal.ReleaseComO bject(sheet);
sheet = null;
System.Runtime.InteropServices.Marshal.ReleaseComO bject(workbook);
workbook = null;



" Scott M." < s - *** @nospam.nospamschrieb:
"Scott M." <s-***@nospam.nospamschrieb:

尝试在调用ReleaseCOMObject之前添加以下内容:


sheet = null;

workbook = null;
Try adding the following just BEFORE your call ReleaseCOMObject on them:

sheet = null;
workbook = null;



坏主意,因为''ReleaseComObject''如果传递null

引用,就不会释放对象。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/> ;

VB< URL:http://dotnet.mvps.org/dotnet/faqs/>

Bad idea, because ''ReleaseComObject'' won''t release the objects if a null
reference is passed to it.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


< ; ch ********** @ hotmail.comschrieb:
<ch**********@hotmail.comschrieb:

我正在努力释放com对象。我

已将问题隔离到下面的代码中。对象被释放并且

过程结束,直到我使用int k = sheet.Count;然后该过程不会结束。
I am struggling with releasing com objects. I
have isolated the problem to the code below. Objects are released and
the process ends until I
use "int k = sheet.Count;" Then the process does not end.



PRB:Office应用程序在从Visual Studio自动化后不会退出

..NET客户端

<网址:http://support.microsoft.com/?scid = kb; EN-US; 317109>

- "疑难解答>


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL :http://dotnet.mvps.org/dotnet/faqs/>

PRB: Office Application Does Not Quit After Automation from Visual Studio
..NET Client
<URL:http://support.microsoft.com/?scid=kb;EN-US;317109>
-"Troubleshooting"

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


这篇关于excel进程无法正常终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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