学习
解决方案 »
- c# 定义接口 及其实现
- 我在普通的显示器(1280×1024)下面开发的winform程序,其中一个panel需要一个背景图片,在1280*800的分辨率下面为什么图片显示不完整啊
- JS与C#2进制传输
- 调用了openfiledialog后 窗体上无法载入磁盘中的图片文件了
- C#读写文本
- 求助C#一个非常简单的程序
- DataSet 排序问题?
- 谁做过声讯台方面的项目呀!(类似1860)
- c# dataset结果集序列化后如何进行压缩
- (会者不难,难者不会)在Excel的COM组件中单元格对应的公式怎么取得。
- 100分紧急求助各位大侠,求解datagridview数据编辑方面的问题解决方法
- c#(winform)单元格焦点的问题
ExcelApplication=nothing
For Each thisproc As Process In Process.GetProcessesByName(processName)
If thisproc.CloseMainWindow = False Then
thisproc.Kill()
End If
Next
End Sub
教你一個方法﹕調用后立即使用GC回收它就可以。OpenNewExcelApp();
GC.Collect();OpenNewExcelApp();
{
Excel.ApplicationClass exec= new Excel.ApplicationClass();
exec.Visible = true ;
try
{
你的代碼區
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
finally
{
if(exec!=null)exec = null;
}
}
也就是上面的 finally語句塊
另外杀死进程能杀死不同id号的进程就好了,学习中
m_objQryTable = null;System.Runtime.InteropServices.Marshal.ReleaseComObject((object)m_objQryTables);
m_objQryTables = null;System.Runtime.InteropServices.Marshal.ReleaseComObject((object)m_objRange);
m_objRange = null;System.Runtime.InteropServices.Marshal.ReleaseComObject((object)m_objSheet);
m_objSheet = null;System.Runtime.InteropServices.Marshal.ReleaseComObject((object)m_objSheets);
m_objSheets = null;m_objBook.Close(false,m_objOpt,m_objOpt);
System.Runtime.InteropServices.Marshal.ReleaseComObject((object)m_objBook);
m_objBook = null;m_objBooks.Close();
System.Runtime.InteropServices.Marshal.ReleaseComObject((object)m_objBooks);
m_objBooks = null;m_objExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject((object)m_objExcel);
m_objExcel = null;GC.Collect();
GC.WaitForPendingFinalizers();