0
當我們嘗試關閉excel對象時,它無法關閉到羣集環境。在QA和UAT環境中工作正常。Excel進程在羣集環境中沒有結束
public bool KillExcelProcess()
{
try
{
object misValue = System.Reflection.Missing.Value;
wbObj.Save();
wbObj.Close(true, misValue, misValue);
appC.Workbooks.Close();
appC.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(objSheet);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wbObj);
System.Runtime.InteropServices.Marshal.ReleaseComObject(appC);
wbObj = null;
appC = null;
}
catch (Exception ex)
{
//throw ex;
}
finally
{
System.Threading.Thread.Sleep(5000);
GC.Collect();
}
return true;
調用函數
#endregion
try
{
log.Info("CloseExcelService (MeasureSavingsComputeBO) Starts ...");
exConverter.KillExcelProcess();
while (true)
{
try
{
File.Delete(strFilename);
break;
}
catch (Exception ex)
{
}
}