如何使用 C# 调用 qtp 的对象存储库库

发布于 2024-12-10 14:26:31 字数 1822 浏览 5 评论 0原文

我最近遇到了一个问题。我想使用 C# 调用 QTP 的对象存储库库,但它不起作用。 code:

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   

I met a problem recently. I want to invoke the QTP's Object Repository Lib using C#, but it doesn't work.
code:

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

but I recieved a System.InvalidCastException when the program runs to or.GetAllObjects();, I don't see any cast operation here, how can I get such exception?
Does anyone has some ideas? Thanks.

here is the stacktrace:

    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   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走就滚别墨迹 2024-12-17 14:26:31

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

QTP object repository is accessible using reflection. Use of reflection will help to get rid of the above error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文