API call from VS to Ranorex.Imaging.Contains killing script

Class library usage, coding and language questions.
User avatar
Aracknid
Posts: 363
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

API call from VS to Ranorex.Imaging.Contains killing script

Post by Aracknid » Wed Jan 16, 2019 9:53 pm

Hi,

Using latest Ranorex 8.3.2, and in my code I'm making a call to Ranorex.Imaging.Contains. At this point in my code, there's a bit of a delay and then Visual Studio just stops running the script. So, it goes from running to stopped (not break mode). I have try/catch surrounding this code and it doesn't generate an exception.

This was working last time I ran it using Ranorex 8.3.0 (the code is not new or modified).

Here's a sample of my code:
    'This Function is looking at a Silverlight control of a table, and trying to determine which row is 'selected' by looking at the color
	'of the cell. A selected row will have a different color than unselected rows. There was no other easy way to determine a selected row'in this Silverlight object.
	Public Function get_ActiveRowWithFocusOnTaskName() As Integer

        Dim lFootprint As String = "Module: " & mcs_ModuleName & ", Function: " & (New StackFrame()).GetMethod.Name & " :: "
        Dim PWTable As Ranorex.Unknown
        Dim PWRow As Ranorex.Unknown
        Dim PWCol As Ranorex.Unknown
        Dim iRow As Integer
        Dim iCurrentIndex As Integer = 1
        Dim bFoundTask As Boolean = False
        Dim bMatch As Boolean
        Dim oBMP As Bitmap

        Try

            Autoweb.logInfo(lFootprint)

            If System.Diagnostics.Debugger.IsAttached Then
                If Not My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath & "\Bitmaps\ProjectWorksheet\Blue_Cell_Blank.bmp") Then
                    'You need to copy the BMP's from the build server or C:\Ranorex_Scripts\v18 folder for this to work
                    Stop
                End If
            End If

			oBMP = Ranorex.Imaging.Load(My.Application.Info.DirectoryPath & "\Bitmaps\ProjectWorksheet\selected_row_TaskNameCol_focused_task_icon_only.bmp")

            PWTable = SilverlightControl & "/container/table/element[@automationid='RowsPresenter']"
            PWTable.EnsureVisible()

            Ranorex.Imaging.FindOptions.Default.Similarity = 0.9999

            'Iterate through the rows, looking at the column that has the Task Name, if it's the one you want, click the icon beside
            'it (if it's editable, clicking the name will go into edit mode)
            For iRow = 0 To PWTable.Children.Count - 1

                PWRow = PWTable.Children.Item(iRow)
                If PWRow.Visible Then

                    PWCol = PWRow.Children.Item(TaskNameCol)
                    If Not PWCol.Visible Then
                        PWCol.EnsureVisible()
                    End If

					''' This call is just dying in 8.3.2. No exception thrown. Was working in 8.3.0
                    bMatch = Ranorex.Imaging.Contains(PWCol, oBMP)
					
                    If bMatch Then
                        ActiveRow = iRow + 1
                        Return iRow + 1
                    End If

                End If

            Next

            Return 0

        Catch ex As RanorexException
            Autoweb.logError(lFootprint & "A Ranorex Exception Occurred --> " & ex.Message)
            Return -1
        Catch ex As Exception
            Autoweb.logError(lFootprint & "An Exception Occurred --> " & ex.Message)
            Return -1
        End Try

    End Function

ahoisl
Certified Professional
Certified Professional
Posts: 179
Joined: Fri Sep 07, 2007 8:16 am

Re: API call from VS to Ranorex.Imaging.Contains killing script

Post by ahoisl » Thu Jan 17, 2019 10:38 am

Aracknid wrote:
Wed Jan 16, 2019 9:53 pm
This was working last time I ran it using Ranorex 8.3.0 (the code is not new or modified).
We don't know of any issue like this with 8.3.2, yet. And we were not able to reproduce the problem, either.

Does this happen on a single/specific machine/operating system only?
Do you get any error text when running the test from a Windows command line?
Do you see any error message in the Windows Event Log? If you cannot catch the exception, it's apparently a hard crash.

Regards,
Alex
Ranorex Team

User avatar
Aracknid
Posts: 363
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: API call from VS to Ranorex.Imaging.Contains killing script

Post by Aracknid » Thu Jan 17, 2019 4:15 pm

Currently, all my systems are Windows 10. It is happening on at least 3 systems I tried it on. But they are all VM's and pretty much identical.

There's no error text when run from command line.

There is something in the event log related to this. It is in the Error, Application Error section. There is one entry for every time I tried to run, and they are all the same:

Faulting application name: PROMGT_PROJWORKSHEET_BAT_08.vshost.exe, version: 14.0.23107.0, time stamp: 0x559b788a
Faulting module name: clr.dll, version: 4.7.3190.0, time stamp: 0x5b694768
Exception code: 0xc0000005
Fault offset: 0x0000eee3
Faulting process id: 0x1e28
Faulting application start time: 0x01d4adcc6f0e2212
Faulting application path: C:\TFS\xxxxxxxxx\Debug\PROMGT_PROJWORKSHEET_BAT_08.vshost.exe
Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Report Id: 30c20f66-8d93-4eff-91cb-42b9fb6ab9bc
Faulting package full name:
Faulting package-relative application ID:

ahoisl
Certified Professional
Certified Professional
Posts: 179
Joined: Fri Sep 07, 2007 8:16 am

Re: API call from VS to Ranorex.Imaging.Contains killing script

Post by ahoisl » Thu Jan 17, 2019 10:16 pm

The error message suggests an access violation in "clr.dll", which is the basic runtime DLL for .NET. This is unfortunately not very helpful since the error does not hold any information related to Ranorex :|

A few things you can try:
  • Reinstall .NET
  • Roll back to 8.3.1 (or 8.3.0) and see if the issue persists
  • Reinstall Ranorex 8.3.2 and all prerequisites (with the Ranorex-*.exe setup package)
  • Rename the "VCRedist" folder in the "<Ranorex Install dir>\bin\Runtime" (if your test runs as x86 bit, otherwise rename the folder in the "x64" subfolder). If this does not fix it, make sure to rename the folder back to the original name
  • Try with a different image whether you also get the crash
  • Provide us with a small (as small as possible) example that we reproduce the problem with
I hope we can narrow down the problem that way...

Regards,
Alex
Ranorex Team