Loading an assembly with reflection fails with File is corrupt. HRESULT 0x8013110E because there are too many properties in the assembly?

2

We have an assembly which fails to load with reflection - it gives File is corrupt. HRESULT 0x8013110E It does not matter how to load the assembly - could be Assembly.LoadFile or Add-Type -Path on the powershell console.

I am already trained to check for 32 vs 64 bits, but turns out this is not the case at all. What happens is that we have too many properties in the assembly. I am certain this is the cause, because removing any property (and building) solves the problem - the assembly can be loaded with reflection again.

I have examined the assembly with ildasm, observe:

C:\temp> ildasm.exe xyz.dll /stats /out=c:\temp\1.txt
C:\temp> cat C:\temp\1.txt | sls '\bFieldDef\b'

//   FieldDef      - 65534 (655340 bytes) 181 constant

Looks like a pretty clear 16 bits limit on FieldDef.

Is anyone aware of this? Is this documented anywhere? This is very unexpected - the code builds cleanly, but fails to load with reflection (we need it).

c#
.net
asked on Stack Overflow Dec 5, 2019 by mark

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0