本文整理匯總了C#中NetOffice.COMObject.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# COMObject.Dispose方法的具體用法?C# COMObject.Dispose怎麽用?C# COMObject.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NetOffice.COMObject
的用法示例。
在下文中一共展示了COMObject.Dispose方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DoTest
public TestResult DoTest()
{
Excel.Application application = null;
DateTime startTime = DateTime.Now;
try
{
application = new NetOffice.ExcelApi.Application();
application.Visible = true;
application.DisplayAlerts = false;
application.Workbooks.Add();
Excel.Worksheet sheet = application.Workbooks[1].Sheets[1] as Excel.Worksheet;
Office.COMAddIn addin = (from a in application.COMAddIns where a.ProgId == "ExcelAddinCSharp.TestAddin" select a).FirstOrDefault();
if(null == addin)
return new TestResult(false, DateTime.Now.Subtract(startTime), "COMAddin ExcelAddinCSharp.TestAddin not found.", null, "");
bool ribbonIsOkay = false;
bool taskPaneIsOkay = false;
if (null != addin.Object)
{
COMObject addinProxy = new COMObject(null, addin.Object);
ribbonIsOkay = (bool)Invoker.PropertyGet(addinProxy, "RibbonUIPassed");
taskPaneIsOkay = (bool)Invoker.PropertyGet(addinProxy, "TaskPanePassed");
addinProxy.Dispose();
}
if( ribbonIsOkay && taskPaneIsOkay)
return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
else
return new TestResult(false, DateTime.Now.Subtract(startTime), string.Format("Ribbon:{0} TaskPane:{1}", ribbonIsOkay, taskPaneIsOkay), null, "");
}
catch (Exception exception)
{
return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
}
finally
{
if (null != application)
{
application.Quit();
application.Dispose();
}
}
}
示例2: DoTest
public TestResult DoTest()
{
Excel.Application application = null;
DateTime startTime = DateTime.Now;
try
{
application = new NetOffice.ExcelApi.Application();
application.Visible = true;
application.DisplayAlerts = false;
application.Workbooks.Add();
Excel.Worksheet sheet = application.Workbooks[1].Sheets[1] as Excel.Worksheet;
Office.COMAddIn addin = (from a in application.COMAddIns where a.ProgId == "NOTestsMain.ExcelTestAddinCSharp" select a).FirstOrDefault();
if (null == addin || null == addin.Object)
return new TestResult(false, DateTime.Now.Subtract(startTime), "NOTestsMain.ExcelTestAddinCSharp or addin.Object not found.", null, "");
bool addinStatusOkay = false;
string errorDescription = string.Empty;
if (null != addin.Object)
{
COMObject addinProxy = new COMObject(addin.Object);
addinStatusOkay = (bool)Invoker.Default.PropertyGet(addinProxy, "StatusOkay");
errorDescription = (string)Invoker.Default.PropertyGet(addinProxy, "StatusDescription");
addinProxy.Dispose();
}
if (addinStatusOkay)
return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
else
return new TestResult(false, DateTime.Now.Subtract(startTime), string.Format("NOTestsMain.ExcelTestAddinCSharp Addin Status {0}", errorDescription), null, "");
}
catch (Exception exception)
{
return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
}
finally
{
if (null != application)
{
application.Quit();
application.Dispose();
}
}
}
示例3: DoTest
public TestResult DoTest()
{
Word.Application application = null;
DateTime startTime = DateTime.Now;
try
{
application = new Word.Application();
application.Visible = true;
application.DisplayAlerts = Word.Enums.WdAlertLevel.wdAlertsNone;
application.Documents.Add();
Office.COMAddIn addin = (from a in application.COMAddIns where a.ProgId == "NOTestsMain.WordTestAddinCSharp" select a).FirstOrDefault();
if (null == addin || null == addin.Object)
return new TestResult(false, DateTime.Now.Subtract(startTime), "NOTestsMain.WordTestAddinCSharp or addin.Object not found.", null, "");
bool addinStatusOkay = false;
string errorDescription = string.Empty;
if (null != addin.Object)
{
COMObject addinProxy = new COMObject(addin.Object);
addinStatusOkay = (bool)Invoker.Default.PropertyGet(addinProxy, "StatusOkay");
errorDescription = (string)Invoker.Default.PropertyGet(addinProxy, "StatusDescription");
addinProxy.Dispose();
}
if (addinStatusOkay)
return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
else
return new TestResult(false, DateTime.Now.Subtract(startTime), string.Format("NOTestsMain.WordTestAddinCSharp Addin Status {0}", errorDescription), null, "");
}
catch (Exception exception)
{
return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
}
finally
{
if (null != application)
{
application.Quit(WdSaveOptions.wdDoNotSaveChanges);
application.Dispose();
}
}
}
示例4: _excelApplication_SheetActivateEvent
private void _excelApplication_SheetActivateEvent(COMObject Sh)
{
textBoxEvents.BeginInvoke(_updateDelegate, new object[] { "Event SheetActivate called." });
Sh.Dispose();
}
示例5: ExcelApplication_SheetDeactivateEvent
void ExcelApplication_SheetDeactivateEvent(COMObject Sh)
{
_sheetDeactivateEvent = true;
Sh.Dispose();
}