【问题标题】:how to invoke qtp's object repository lib using C#如何使用 C# 调用 qtp 的对象存储库库
【发布时间】:2011-10-18 02:34:01
【问题描述】:

我最近遇到了一个问题。我想使用 C# 调用 QTP 的 Object Repository Lib,但它不起作用。 代码:

REPOSITORYUTILLib.ObjectRepositoryUtil or = new REPOSITORYUTILLib.ObjectRepositoryUtil();
or.Load(@"C:\Repository.tsr");
or.GetAllObjects();

但是当程序运行到or.GetAllObjects(); 时我收到了System.InvalidCastException,我在这里看不到任何强制转换操作,我怎么会得到这样的异常? 有没有人有一些想法?谢谢。

这里是堆栈跟踪:

    mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(objectarg,System.Type    paramType) + 0xe7 bytes   
    mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(System.Runtime.Remoting.Messaging.IMessage msg, object[] outArgs, object returnValue) + 0x88 bytes    
mscorlib.dll!System.RuntimeType.ForwardCallToInvokeMember(string memberName, System.Reflection.BindingFlags flags, object target, int[] aWrapperTypes, ref System.Runtime.Remoting.Proxies.MessageData msgData) + 0x26e bytes

test.exe!test.test.Main() lines 14 + 0xf bytes  C#

mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile,     System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x6d bytes    
    Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2a bytes  
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes   
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes    
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes    
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes   

【问题讨论】:

  • 嗨@Polity,感谢您的回复,我只是在这里发布堆栈跟踪。

标签: c# qtp


【解决方案1】:

可以使用反射访问 QTP 对象存储库。使用反射将有助于摆脱上述错误。

【讨论】:

    猜你喜欢
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多