question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.IO.FileNotFoundException: Could not find file "/mscorlib.dll"

See original GitHub issue

Version Used: 3.3.1 CodeAnalysis scripting crashed

 _options = ScriptOptions.Default
                    .AddReferences(
                        typeof(System.Guid).Assembly,
                        typeof(System.DateTime).Assembly,
                        typeof(IQueryablePagingExtensions).Assembly);`

>  System.TypeInitializationException: The type initializer for 'blaze.clients.shared.Extensions.IQueryablePagingExtensions' threw an exception. ---> System.IO.FileNotFoundException: Could not find file "/mscorlib.dll"
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) <0x4502058 + 0x002ca> in <b883731ddd174c84b6d28072a5ecfbb7>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) <0x44f8558 + 0x0001e> in <b883731ddd174c84b6d28072a5ecfbb7>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at System.IO.File.OpenRead (System.String path) <0x44f8490 + 0x0000a> in <b883731ddd174c84b6d28072a5ecfbb7>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Roslyn.Utilities.FileUtilities.OpenFileStream (System.String path) <0x44f82b8 + 0x0005e> in <a31c2e7fc2484532bec3a244fde7efbf>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.MetadataReference.CreateFromAssemblyInternal (System.Reflection.Assembly assembly, Microsoft.CodeAnalysis.MetadataReferenceProperties properties, Microsoft.CodeAnalysis.DocumentationProvider documentation) <0x44ef9c0 + 0x00088> in <a31c2e7fc2484532bec3a244fde7efbf>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.Scripting.ScriptOptions.CreateReferenceFromAssembly (System.Reflection.Assembly assembly) <0x44ef520 + 0x00010> in <3f16222c2b534ca383a9db0f1737ef50>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at (wrapper delegate-invoke) System.Func`2[System.Reflection.Assembly,Microsoft.CodeAnalysis.MetadataReference].invoke_TResult_T(System.Reflection.Assembly)
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.Scripting.ParameterValidationHelpers+<>c__DisplayClass4_0`2[T,S].<SelectChecked>b__0 (T item) <0x44ef440 + 0x0002c> in <3f16222c2b534ca383a9db0f1737ef50>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at (wrapper delegate-invoke) System.Func`2[System.Reflection.Assembly,Microsoft.CodeAnalysis.MetadataReference].invoke_TResult_T(System.Reflection.Assembly)
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].MoveNext () <0x44ef1f8 + 0x00062> in <f6f4ba026f444d0c8ea39799e4d0b3cb>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.Scripting.ParameterValidationHelpers.AddRangeChecked[T] (Microsoft.CodeAnalysis.ArrayBuilder`1[T] builder, System.Collections.Generic.IEnumerable`1[T] items, System.String parameterName) <0x44eedc0 + 0x00096> in <3f16222c2b534ca383a9db0f1737ef50>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.Scripting.ParameterValidationHelpers.ConcatChecked[T] (System.Collections.Immutable.ImmutableArray`1[T] existing, System.Collections.Generic.IEnumerable`1[T] items, System.String parameterName) <0x44e2e60 + 0x00028> in <3f16222c2b534ca383a9db0f1737ef50>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.Scripting.ScriptOptions.AddReferences (System.Collections.Generic.IEnumerable`1[T] references) <0x44e2c18 + 0x00020> in <3f16222c2b534ca383a9db0f1737ef50>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.Scripting.ScriptOptions.AddReferences (System.Collections.Generic.IEnumerable`1[T] references) <0x44d5f20 + 0x0001e> in <3f16222c2b534ca383a9db0f1737ef50>:0 
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at Microsoft.CodeAnalysis.Scripting.ScriptOptions.AddReferences (System.Reflection.Assembly[] references) <0x44d5c00 + 0x00008> in <3f16222c2b534ca383a9db0f1737ef50>:0 

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ordinaryorangecommented, May 26, 2020

@tmat you are correct in that assemblies are not stored on disk. However I think the underlying culprit here is that the Script api has a dependency on a file system being available, and the assembly being on it.

This line eventually calls File.OpenRead() and there appears no way to circumvent that.

If coreLib was resolved via a MetaDataReferenceResolver as all the other assemblies are/can be (via Options.MetadataReferences) then it would be possible to supply a custom MetadaReferenceResolver for code executing in Bazor style hosts which do not store the assemblies on disk.

I’m unsure why CorLib has been treated differently than all other assemblies, and does seem to be an implementation oversight to seek CoreLib from the disk when MetaDataReferenceResolver extensibility has been baked in?

0reactions
gfscommented, Aug 24, 2020

@Arestis How did you overcome the limitation @ordinaryorange mentions?

I am currently blocked here because of the hard dependency on mscorlib.dll being on disc - I am passing in the in memory meta data references for everything I need (including mscorlib).

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.IO.FileNotFoundException occuring in mscorlib.dll?
System.IO.FileNotFoundException occuring in mscorlib.dll? ... 1) Add the DLLs to the project in a local Folder and set them to "Embedded Resources ...
Read more >
Exception thrown: 'System.IO.FileNotFoundException' in ...
I can't get this to run. I keep getting a Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll error and then visual studio ...
Read more >
mscorlib system.io.filenotfoundexception missing file name
Don't use the . · Try the command "sfc /scannow" from an elevated command prompt · Click Start · Right-click Command Prompt, click...
Read more >
Debugging System.IO.FileNotFoundException - Cause and fix
As the message says, you are trying to load a file that couldn't be found. This type of error can be re-created using...
Read more >
"System.IO.FileNotFoundException occured in mscorlib.dll ...
Hello, I'm getting a bunch of "A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll" exceptions ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found