IOException error when writing modified Assembly #933
-
I've successfully managed to read and modify an Assembly within my code. However, when I try to write this Assembly back to the original file with the AssemblyDefinition.Write(path) function, it immediately crashes with an IOException. Here's my code:
And here's the text of the error:
Everything works until the NormalAssembly.Write() call, at which point that error occurs. The file path, type I'm accessing, etc are all valid. Additionally, I've used Process Explorer to look for all hooks to that DLL, and the only one that ever occurs is a single hook from this process. The process that uses the DLL is never running. This error occurs even immediately after restarting my entire PC. I'm on version 0.11.5 of Mono.Cecil, and DotNet 8.0.201. Sorry in advance if I'm just missing something obvious, or if this is the wrong place to ask. I just can't find practically any documentation online for the library, and I can't locate anybody having the same problem that I haven't already covered. Thanks in advance for the help, and let me know if there's any other information that would be helpful to provide. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Since you're writing to the same path you read from, have you tried the overload without a parameter: By default, the assembly file is kept open (probably due to the fact the |
Beta Was this translation helpful? Give feedback.
Since you're writing to the same path you read from, have you tried the overload without a parameter:
NormalAssembly.Write();
?By default, the assembly file is kept open (probably due to the fact the
ReaderParameters.ReadingMode
property is set toDeferred
).