C#
C#

help

Root Question Message

Surihia
Surihia2/9/2023
❔ What does this exception mean?

(Sorry for reposting as I already put it in the help chat and don't want it to get buried)

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

Basically I am passing a File Path as a string to another classfile and this classfile uses a dll and reads the File provided to a array. as soon as it gets to the code that do a value change onto the file, this exception is thrown.
The File in question is not accessed or being used by any other method and the path is correctly seen in the class file too.
AntonC
AntonC2/9/2023
I would guess the string isn't null terminated
AntonC
AntonC2/9/2023
your dll reads beyond the string memory because it doesn't rely on the length
AntonC
AntonC2/9/2023
strings in c# are wide, there might be a weird problem with that
Ero
Ero2/9/2023
probably an issue with the dll/libraryimport, yeah
Ero
Ero2/9/2023
you can (should) either specify the string marshalling, or straight up pass the correct type (sbyte* or ushort*)
Surihia
Surihia2/9/2023
how do I do this ?
Ero
Ero2/9/2023
i don't exactly know what your native signature looks like. can't help that much
Surihia
Surihia2/9/2023
nvm. I am not gonna use this library in the end.
Surihia
Surihia2/9/2023
gonna fallback to the old one
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy