我有一个用C#开发的应用程序测试框架,它在每一步之后将结果存储在Excel文件中。在解决方案中执行时一切正常。但是当我将解决方案与Fitnesse集成并调用该方法时,会抛出错误。我在下面的Fitness中添加了堆栈跟踪。
代码段位于:
public class ExcelReports : IReporter
{
private Excel.Application xlReport;
public ExcelReports()
{
xlReport = new Excel.Application();
Excel.Workbook xlWorkbook = xlReport.Workbooks.Add();
***xlWorkbook.SaveAs(ExecutionContext.RESULTFILE);***
}
}
xlWorkbook.SaveAs(ExecutionContext.RESULTFILE)报告错误
我正在使用适用于.NET 4.0版本的fit和fitsharp dll。
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException: Microsoft Excel cannot access the file
'C:\0452CB00'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open
workbook.
at Microsoft.Office.Interop.Excel._Workbook.SaveAs(Object Filename, Object
FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended,
Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution,
Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local)
at EF.UIAutomation.Commons.ExcelReports..ctor() in
C:\EF.Automation\EF.UIAutomation.PageLibrary\Libraries\EF.UIAutomation.Commons.Reports.cs:l ine 25
at EF.UIAutomation.Launcher.Program.Test() in
C:\EF.Automation\EF.Automation\Program.cs:line 26
--- End of inner exception stack trace ---
at fitSharp.Machine.Model.TypedValue.ThrowExceptionIfNotValid()
at fitSharp.Fit.Operators.CompareDefault.Compare(TypedValue actualValue, Tree`1
expected)
at fitSharp.Machine.Engine.ProcessorBase`2.<>c__DisplayClass3.
<>c__DisplayClass5.b__2(CompareOperator`1 o)
at fitSharp.Machine.Engine.Operators`2.Do[O](CanDoOperation`1 canDoOperation,
DoOperation`1 doOperation)
at fitSharp.Machine.Engine.ProcessorBase`2.
<>c__DisplayClass3.b__0(OperationLogging logging)
at fitSharp.Machine.Engine.ProcessorBase`2.DoLoggedOperation[R](String
startMessage, Func`2 operation)
at fitSharp.Machine.Engine.ProcessorBase`2.Compare(TypedValue instance, Tree`1
parameters)
at fitSharp.Fit.Operators.CheckDefault.Check(CellOperationValue actualValue,
Tree`1 expectedCell)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[]
parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder
binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParams)
at fitSharp.Machine.Engine.MethodMember.TryInvoke(Object[] parameters)
at fitSharp.Machine.Engine.ReflectionMember.Invoke(Object[] parameters)
at fitSharp.Machine.Engine.ProcessorBase`2.Operate[O](Object[] parameters)
at fitSharp.Fit.Engine.CellProcessorExtension.Check(CellProcessor processor,
Object systemUnderTest, Tree`1 memberName, Tree`1 parameters, Tree`1 expectedCell)
at fitSharp.Fit.Service.CheckBinding.Do(Tree`1 cell)
at fitSharp.Fit.Service.Binding.Do(Tree`1 cell)
at fit.ColumnFixture.DoCell(Parse cell, Int32 column)