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

Bad Cast Exception Partially Crashes Program, Prevents from Working #10

Open
rothn opened this issue Dec 20, 2024 · 5 comments
Open

Bad Cast Exception Partially Crashes Program, Prevents from Working #10

rothn opened this issue Dec 20, 2024 · 5 comments

Comments

@rothn
Copy link

rothn commented Dec 20, 2024

I get an exception on 1.5.1, which crashes the program. The web interface only displays a heading "Not Found (Not Found)" but does appear to be a working HTTP server.

An unexpected error occurred. Should you like assistance with this error, please assist those assisting you by copying the indented text into your request for assistance. The error was:
    = Tiny UI Fix version 1.5.1, running on PowerShell v7.4.6, on Unix 6.12.3.1 =
    Cannot convert the "System.ValueTuple`2[TinyUIFixForTS3ResourceCFGDirective,System.Object][]" value of type "System.ValueTuple`2[[TinyUIFixForTS3ResourceCFGDirective, PowerShell Class Assembly, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]][]" to type "System.Collections.Generic.IEnumerable`1[System.ValueTuple`2[TinyUIFixForTS3ResourceCFGDirective,System.Object]]".
    HRESULT: 80004002
    The type of error was: System.Management.Automation.PSInvalidCastException
    The line that caused the error was: while ($Lines.MoveNext())
    The error occurred:
        at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType)
        at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
        at CallSite.Target(Closure, CallSite, ValueTuple`2[])
        at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
        at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
        at ExtractDirectivesFromResourceCFG, /home/nroth/tiny-ui-fix-for-ts3/Use-TinyUIFixForTS3.ps1: line 1846
        at <ScriptBlock>, /home/nroth/tiny-ui-fix-for-ts3/Use-TinyUIFixForTS3.ps1: line 2351
        at Resolve-ResourcePrioritiesForSims3Installation, /home/nroth/tiny-ui-fix-for-ts3/Use-TinyUIFixForTS3.ps1: line 2374
        at Resolve-ResourcePrioritiesForSims3InstallationForUIScaling, /home/nroth/tiny-ui-fix-for-ts3/Use-TinyUIFixForTS3.ps1: line 5536
        at <ScriptBlock>, /home/nroth/tiny-ui-fix-for-ts3/Use-TinyUIFixForTS3.ps1: line 6767
        at <ScriptBlock>, <No file>: line 1
@rothn
Copy link
Author

rothn commented Dec 20, 2024

OS: Fully up-to-date Arch Linux

@rothn
Copy link
Author

rothn commented Dec 20, 2024

Note-- this is right next to a comment "Without this totally redundant assignment, $Lines.MoveNext() fails with a System.Management.Automation.PSInvalidCastException.", though that appears to be exactly what happens here, so perhaps the redundant assignment does not fully resolve the issue.

@rothn
Copy link
Author

rothn commented Dec 20, 2024

Okay, this is super weird. I commented out the redundant assignment, and now it works for me. This is maddening, since that line should not have any semantic meaning at all. Am I just going crazy?

@just-harry
Copy link
Owner

This is maddening, since that line should not have any semantic meaning at all. Am I just going crazy?

"We’re all mad here. I’m mad. You’re mad."

The PowerShell runtime has a number of bugs that manifest in impossibilities occurring.

I've encountered a behaviour wherein scripts that load .NET assemblies (like this one) will fail (at some expression) the first time they're run, and will then continue to fail on each run – but then if the script's source-code is modified, it will suddenly start working (within a PowerShell instance that has previously failed in that script), as though some kind of faulty internal cache is being partially cleared ¯\(ツ)

That could be what caused it to start working for you.

I'm thinking this might be a difference between operating-systems—I'm spinning up an Arch VM now to give it a try.

@just-harry
Copy link
Owner

Okay, I've looked into it—it seems as though this is caused by the Mods/Resource.cfg file in the user-data directory being empty, or at-least that's how I can replicate it.

At any rate, I'll have to workaround that.

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