Open danyhm opened 4 months ago
here is the initial stacktrace.
{System.BadImageFormatException: Corrupt .resources file. Unable to read resources from this file because of invalid header information. Try regenerating the .resources file. ---> System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.__Error.EndOfFile()
at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
at System.IO.BinaryReader.ReadInt32()
at System.Resources.ResourceReader._ReadResources()
at System.Resources.ResourceReader.ReadResources()
at System.Resources.ResourceReader.ReadResources()
at System.Resources.ResourceReader..ctor(Stream stream)
It does not matter if I add a resource to the file or remove a resource to the file , this exception is always thrown. the resources are a lot BTW if that has to do something with it.
also trying to extract the resources with ResGen
Fails
Read in 101 resources from "AH.resources"
Read in 16423 resources from "LH.resources"
Read in 99 resources from "TH.resources"
ResGen : error RG0000: Error while writing the output file "./AH.resw"
ResGen : error RG0000: Specific exception: "InvalidOperationException" Message: "Item named '72' of type 'System.IO.UnmanagedMemoryStream' cannot be added to the resource file because it is not serializable."
2 error(s).
Hello,
Sorry for the late response! Could you provide a minimum reproduce case with the files you used and the changes you made? If you do not wish to give this publically, you can send it to me via email elektrokilldev@protonmail.com
Thanks in advance
Hi, I sent you the email.
If you edit any of the resource strings the final program won't be able to read the resources and will fail with the errors mentioned above.
there was some update recenly in ILSPy about resources support - https://github.com/icsharpcode/ILSpy/commit/f9ae51b12adb0eb3a056d7b428f2ee1977c18768
is it related to this topic?
Hi, even when trying resgen
with your original file it fails to execute:
Read in 101 resources from "Genetec.Platform.Resources.AppearanceHook.resources"
Read in 16423 resources from "Genetec.Platform.Resources.LanguageHook.resources"
Read in 99 resources from "Genetec.Platform.Resources.TrademarkHook.resources"
ResGen : error RG0000: Error while writing the output file "sds\Genetec.Platform.Resources.AppearanceHook.resw"
ResGen : error RG0000: Specific exception: "InvalidOperationException" Message: "Item named '72' of type 'System.IO.UnmanagedMemoryStream' cannot be added to the resource file because it is not serializable."
3 error(s).
A file where i used the Edit Resource
option and changed the string produces the exact same error.
This error is not related to the edit and is caused by ResGen not properly supporting data stream resources. ResGen properly parses all resources from the file as seen by the Read in X resources from
messages before and after my edit using dnSpy.
This is visible when debugging ResGen itself in dnSpy where we can see all resource files are properly read.
I cannot reproduce your issue with ResourceReader crashing using the latest build of dnSpyEx
dnSpyEx version
6.5.1
Describe the Bug
Hello,
I'm using the Resource Editor feature and even if I change 1 character in a string resource, while trying to read the resource of the file I get this error at runtime:
Corrupt .resources file. Unable to read resources from this file because of invalid header information. Try regenerating the .resources file.
Stack trace:
How To Reproduce
Edit any resource file and use it in other assemblies.
Expected Behavior
The program should generate the correct header for resource files when saving the modified file.
Actual Behavior
Somehow the header file for resources is not generated correctly
Additional Context
No response