Highlighted
Absent Member.
Absent Member.
1088 views

how to invoke qtp's object repositry lib using C#

hi,all:

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? Or just give me an example how to 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

 

P.S:This thread has been moved from ITRC Qualitu center Forum to QTP-HP Forums Moderator.

Tags (1)
0 Likes
2 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

I think you're missing an argument for the GetAllObjects method there. Can you pass the correct type and see if that helps?


--
Anshoo Arora
Relevant Codes
LinkedIn
0 Likes
Highlighted
New Member.

Syntax

object.GetAllObjects ([Parent])

 

some parent object u need to specify under which the objects exists.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.