79464739

Date: 2025-02-24 20:39:32
Score: 2
Natty:
Report link

After much research, this is my understanding.

In the case of .Net 9, BinaryFormatter is completely removed by default. Trying to use it will cause an error.

In the case of .Net 8 and .Net Framework 4.8.1: the compiler uses the info in the .resx file to create a binary .resources file. Those binary .resources files are embedded in the executable at compile time. When using the attribute System.Resources.ResXFileRef for the image files in the .resx files, a TypeConverter is used to create the binary .resources file. And since the image data embedded in the executable is already in binary format, BinaryFormatter is not used to extract it at runtime.

In summary, in my case above BinaryFormatter is not used for .Net Framework or .Net 8+. (I'm compiling the same code for both, to meet customer demands)

Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Matt