Commit 70357d6
Load assembly from full path before parsing it as an assembly name
clr.AddReference with a rooted path to a non-managed file (e.g. a native
library) should surface a BadImageFormatException. On Windows that happened
because new AssemblyName(@"C:\...\kernel32.dll") fails to parse, so the code
fell through to LoadAssemblyFullPath -> Assembly.LoadFrom -> BadImageFormat.
On Linux the path "/.../libpython3.10.so.1.0" parses fine as an AssemblyName,
so Assembly.Load(name) ran first and threw FileNotFoundException ("The system
cannot find the file specified") before LoadAssemblyFullPath was reached. This
broke the BadAssembly embedding test on Ubuntu.
Try LoadAssemblyFullPath (which loads an existing file from disk) before the
parse-as-assembly-name path, so a real file on disk yields BadImageFormatException
consistently across platforms. Non-rooted names are unaffected and still fall
through to Assembly.Load.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent ccba56d commit 70357d6
1 file changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
512 | 513 | | |
513 | 514 | | |
514 | 515 | | |
515 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
516 | 521 | | |
517 | 522 | | |
518 | 523 | | |
| |||
0 commit comments