本文整理汇总了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();
}