Ranorex 6.0 unable to call PowerShell script

Class library usage, coding and language questions.
ziasim
Posts: 43
Joined: Wed Dec 16, 2015 4:03 pm

Ranorex 6.0 unable to call PowerShell script

Post by ziasim » Tue May 24, 2016 11:01 am

Hi,

I have written a powershell script and calling it using Ranorex 6.0. Each time it shows an error dialog when I try to execute it. Running same script with v5.4.6 is fine and working nicely.

Is v6.0 stable enough to use for our development work or shall we continue with v5.4.6?

User code file attached which is calling power shell script.

This is what I am getting in exception window

Debugger.DebuggerException: Module is not in collection
---STACKTRACE---
Debugger.DebuggerException: Module is not in collection
Debugger.ModuleCollection.get_Item(ICorDebugModule corModule) +0x3b
Debugger.ManagedCallback.UnloadModule(ICorDebugAppDomain pAppDomain,ICorDebugModule pModule) +0xe
Debugger.ManagedCallbackSwitch.UnloadModule(ICorDebugAppDomain pAppDomain,ICorDebugModule pModule) +0x10
Debugger.ManagedCallbackProxy+<>c__DisplayClass20_0.<UnloadModule>b__0() +0x0
Debugger.MTA2STA+<>c__DisplayClass6_1.<EnqueueCall>b__0() +0x0
Debugger.MTA2STA.PerformCall() +0x47
Debugger.MTA2STA.PerformAllCalls() +0x0
System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) +0x0
System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) +0x20
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx) +0x70
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx) +0x0
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state) +0x2b
System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) +0x37
System.Windows.Forms.Control.InvokeMarshaledCallbacks() +0x63

---ORIGINAL STACKTRACE---
Debugger.DebuggerException: Module is not in collection
at Debugger.ModuleCollection.get_Item(ICorDebugModule corModule)
at Debugger.ManagedCallback.UnloadModule(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule)
at Debugger.ManagedCallbackSwitch.UnloadModule(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule)
at Debugger.ManagedCallbackProxy.<>c__DisplayClass20_0.<UnloadModule>b__0()
at Debugger.MTA2STA.<>c__DisplayClass6_1.<EnqueueCall>b__0()
at Debugger.MTA2STA.PerformCall()
at Debugger.MTA2STA.PerformAllCalls()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
Attachments
CallingPowerShellScript2.cs
(2.95 KiB) Downloaded 44 times
Last edited by ziasim on Tue May 24, 2016 11:13 am, edited 2 times in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3937
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex 6.0 unable to call PowerShell script

Post by odklizec » Tue May 24, 2016 11:10 am

Hi,

Could you please post a screenshot/copied text of the error you are getting?

BTW, do you run your test with attached debugger? If so, try to run it without debugger. If the error does not happen without debugger, then it's most probably a known debugger-related issue in 6.0.

The workaround (until the problem is fixed) is to go to Tools >> Options >> Debugging section and here check Debug 'Just my code' option and uncheck Pause on handled Exceptions. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ziasim
Posts: 43
Joined: Wed Dec 16, 2015 4:03 pm

Re: Ranorex 6.0 unable to call PowerShell script

Post by ziasim » Tue May 24, 2016 12:03 pm

Hi,

I ran script without debugger and it was successful. When we can expect a fix of this problem?

Sometime you really need to use debugger to identify issues in code so we can't disable it for too long.

Thanks for your help.

ziasim
Posts: 43
Joined: Wed Dec 16, 2015 4:03 pm

Re: Ranorex 6.0 unable to call PowerShell script

Post by ziasim » Tue May 24, 2016 12:06 pm

Now this is weird...

I again ran same code with debugger enabled and this time it didn't show any exception as mentioned above. It ran successfully :shock:

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3937
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex 6.0 unable to call PowerShell script

Post by odklizec » Tue May 24, 2016 12:20 pm

That's weird. Anyway, it's good to hear it works now ;)

Just in case it happens again, simply enable/disable the options I've mentioned in my previous post. This would allow you to debug your own code and there should not appear any debugger-related exceptions. I got a confirmation Ranorex folks were able to reproduce some of the debugger exceptions I've sent them, so I'm sure they will do their best to deliver a fixed version soon, probably with some other fixes.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration