Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft .NET Framework error #49

Open
thorrenat opened this issue Jun 10, 2024 · 5 comments
Open

Microsoft .NET Framework error #49

thorrenat opened this issue Jun 10, 2024 · 5 comments

Comments

@thorrenat
Copy link

Hi,
Different times a day I keep getting this error:

image

Details:
Consulte el final de este mensaje para obtener más detalles sobre cómo invocar a la depuración
Just-In-Time (JIT) en lugar de a este cuadro de diálogo.

************** Texto de la excepción **************
System.InvalidOperationException: Colección modificada; puede que no se ejecute la operación de enumeración.
en System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
en System.Collections.Generic.List`1.Enumerator.MoveNextRare()
en AppTestStudio.frmMain.Timer1_Tick(Object sender, EventArgs e) en C:\Users\djhar\Source\Repos\DanielHarrod\AppTestStudio\AppTestStudio\frmMain.cs:línea 3209
en System.Windows.Forms.Timer.OnTick(EventArgs e)
en System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Ensamblados cargados **************
mscorlib
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9241.0 built by: NET481REL1LAST_C
Código base: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

AppTestStudio
Versión del ensamblado: 1.0.0.0
Versión Win32: 1.0.0.15
Código base: file:///C:/Program%20Files/App%20Test%20Studio%20-%20DEL/App%20Test%20Studio/AppTestStudio.exe

System.Windows.Forms
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9181.0 built by: NET481REL1LAST_C
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9236.0 built by: NET481REL1LAST_B
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Drawing
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System.Configuration
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Core
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9241.0 built by: NET481REL1LAST_C
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System.Xml
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

AppTestStudioControls
Versión del ensamblado: 1.0.0.2
Versión Win32: 1.0.0.2
Código base: file:///C:/Program%20Files/App%20Test%20Studio%20-%20DEL/App%20Test%20Studio/AppTestStudioControls.DLL

System.Windows.Forms.resources
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_es_b77a5c561934e089/System.Windows.Forms.resources.dll

Microsoft.GeneratedCode
Versión del ensamblado: 1.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

Gma.System.MouseKeyHook
Versión del ensamblado: 5.6.130.0
Versión Win32: 5.6.130.0
Código base: file:///C:/Program%20Files/App%20Test%20Studio%20-%20DEL/App%20Test%20Studio/Gma.System.MouseKeyHook.DLL

Microsoft.GeneratedCode
Versión del ensamblado: 1.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

Accessibility
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

OpenCvSharp
Versión del ensamblado: 1.0.0.0
Versión Win32: 1.0.0.0
Código base: file:///C:/Program%20Files/App%20Test%20Studio%20-%20DEL/App%20Test%20Studio/OpenCvSharp.DLL

OpenCvSharp.Extensions
Versión del ensamblado: 1.0.0.0
Versión Win32: 1.0.0.0
Código base: file:///C:/Program%20Files/App%20Test%20Studio%20-%20DEL/App%20Test%20Studio/OpenCvSharp.Extensions.DLL

System.IO.Compression
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.IO.Compression/v4.0_4.0.0.0__b77a5c561934e089/System.IO.Compression.dll

System.IO.Compression.FileSystem
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.IO.Compression.FileSystem/v4.0_4.0.0.0__b77a5c561934e089/System.IO.Compression.FileSystem.dll

mscorlib.resources
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9037.0 built by: NET481REL1
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_es_b77a5c561934e089/mscorlib.resources.dll

System.Web
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9232.0 built by: NET481REL1LAST_C
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Web/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.dll

PresentationCore
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9241.0 built by: NET481REL1LAST_C
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll

WindowsBase
Versión del ensamblado: 4.0.0.0
Versión Win32: 4.8.9241.0 built by: NET481REL1LAST_C
Código base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll

************** Depuración JIT **************
Para habilitar la depuración Just In Time (JIT), el archivo de configuración de esta
aplicación o equipo (machine.config) debe tener el
valor jitDebugging establecido en la sección system.windows.forms.
La aplicación también se debe compilar con la depuración
habilitada

Por ejemplo:

Cuando esté habilitada la depuración JIT, cualquier excepción no controlada
se enviará al depurador JIT registrado en el equipo
en lugar de controlarlo mediante el cuadro de diálogo.

Any idea why or how to solve it?
Thanks

@DanielHarrod
Copy link
Owner

Hi Thorrenat,

Thanks for reporting this issue. I'm not sure why it's in Spanish.

I was not able to reproduce this issue, or find it by line number, but I believe that this could be the culprit.
Fix for this issue.

This fix is in the 1.0.17 release.

Let me know if you are still getting an error and I would be happy to investigate it further..

Thanks,

Daniel

@thorrenat
Copy link
Author

Hi Daniel,

Certainly with 1.0.17 I am no longer getting this error.

It would be great to add a function to "jump to" and manage to direct the scrip to a different line of code in case of seeing an event or another. I know right know you can set it to jump back to home or parent but some times is limited, can be useful just to jump to a specific line.
Just to share some ideas

Thanks for this wonderful tool.

Best regards

@DanielHarrod
Copy link
Owner

Hi Thorrenat,

Great suggestions.

Daniel

@thorrenat
Copy link
Author

thorrenat commented Dec 23, 2024

Hi Daniel,

Thanks for adding the GoTo menu, really useful.

Regarding the error reported here I kept getting it several times a day, I downloaded the source code and asked for help to ChatGPT to see how to fix it, here explanation and the changes made to fix it:


Original Problem:
The error was happening at line 3529, specifically in this statement:

if (mbmc.ResolutionHeight == ActionNode.ResolutionHeight)

The ActionNode object could potentially be null because the array tns could be empty or contain elements that are not of type GameNodeAction. Attempting to access properties of a null object caused a NullReferenceException.

Changes Made:
The fix involved adding a null check to ensure that ActionNode is valid before accessing its properties:

if (tns.Length == 1)
{
    GameNodeAction ActionNode = tns[0] as GameNodeAction;

    if (ActionNode != null) // New null check added here
    {
        if (mbmc.ResolutionHeight > 0)
        {
            if (mbmc.ResolutionHeight == ActionNode.ResolutionHeight)
            {
                if (mbmc.ResolutionWidth == ActionNode.ResolutionWidth)
                {
                    ActionNode.Bitmap = mbmc.Bitmap.Clone() as Bitmap;
                    Log("Synching Screenshot: " + ActionNode.Name);
                    BitmapChildren(ActionNode, ActionNode.Bitmap);
                }
            }
        }
    }
    else
    {
        Log("Node is not of type GameNodeAction: " + mbmc.NodeName);
    }
}

Why the Changes Were Necessary:

Safety Check for null:
The addition of if (ActionNode != null) ensures the program will not attempt to access properties or methods of an uninitialized object, thus avoiding the NullReferenceException.

Improved Logging:
In cases where the node was not of the expected type (GameNodeAction), a log message was added to provide more information for debugging (Node is not of type GameNodeAction).

Ensures Application Stability:
By properly handling unexpected conditions, such as a mismatched node type, the application can continue running without crashing or exhibiting undefined behavior.

Summary of the Fix:
The null check safeguards against invalid data and ensures the program gracefully handles unexpected scenarios, preventing runtime exceptions and providing useful diagnostic information.


A part from this I updated the OpenCV nuget package from 4.6 to 4.10.
Looks like now it is solved.

I hope this makes sense and helps.
Regards

@DanielHarrod
Copy link
Owner

Thanks for identifying the issue and detailed information with the null use, I wasn't able to make it happen when I tested it prior to your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants