dotnet / dotnet/maui

[MAUI ][Android][CS-Script]Throw exception 'IO_FileNotFound_FileName' in 'Release' mode

Open
#28,989 4 comments 1 reaction 0 assignees View on GitHub
p/2 platform/android s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
296

Description

### Description

I make a sample use CS-Script. It work well in 'Debug' mode, But throw an Exception in 'Release' mode.

### Steps to Reproduce

Download https://github.com/BaY1251/MauiDebug.git
Open /Script/Script.sln to compile and generate a project
Click the "Click me" button

### Link to public reproduction project repository

https://github.com/BaY1251/MauiDebug.git

### Version with bug

9.0.60 SR6

### Is this a regression from previous behavior?

Not sure, did not test other versions

### Last version that worked well

_No response_

### Affected platforms

Android

### Affected platform versions

Android7.1

### Did you find any workaround?

_No response_

### Relevant log output

```shell
IO_FileNotFound_FileName, /System.Private.CoreLib
at Interop.ThrowExceptionForIoErrno(ErrorInfo , String , Boolean )
at Interop.CheckIo(Error , String , Boolean )
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , OpenFlags , Int32 , Boolean , Boolean& , Func4 )
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , Nullable4 )
at System.IO.Strategies.OSFileStreamStrategy..ctor(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , Nullable1 )
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , Nullable1 )
at System.IO.FileStream..ctor(String , FileMode , FileAccess , FileShare , Int32 , FileOptions , Int64 )
at System.IO.FileStream..ctor(String , FileMode , FileAccess , FileShare , Int32 , FileOptions )
at System.IO.FileStream..ctor(String , FileMode , FileAccess , FileShare , Int32 , Boolean )
at System.IO.FileStream..ctor(String , FileMode , FileAccess , FileShare )
at Roslyn.Utilities.StandardFileSystem.OpenFile(String filePath, FileMode mode, FileAccess access, FileShare share)
at Roslyn.Utilities.CommonCompilerFileSystemExtensions.OpenFileWithNormalizedException(ICommonCompilerFileSystem fileSystem, String filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
at Microsoft.CodeAnalysis.MetadataReference.CreateFromAssemblyInternal(Assembly assembly, MetadataReferenceProperties properties, DocumentationProvider documentation)
at Microsoft.CodeAnalysis.MetadataReference.CreateFromAssemblyInternal(Assembly assembly)
at Microsoft.CodeAnalysis.Scripting.Script.GetReferencesForCompilation(CommonMessageProvider messageProvider, DiagnosticBag diagnostics, MetadataReference languageRuntimeReferenceOpt)
at Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScriptCompiler.CreateSubmission(Script script)
at Microsoft.CodeAnalysis.Scripting.Script.GetCompilation()
at CSScriptLib.RoslynEvaluator.Compile(String scriptText, String scriptFile, CompileInfo info)
at CSScriptLib.EvaluatorBase1[[CSScriptLib.RoslynEvaluator, CSScriptLib, Version=4.9.4.0, Culture=neutral, PublicKeyToken=4c30df19402bb442]].CompileCode(String scriptText)
at CSScriptLib.EvaluatorBase`1[[CSScriptLib.RoslynEvaluator, CSScriptLib, Version=4.9.4.0, Culture=neutral, PublicKeyToken=4c30df19402bb442]].LoadCode(String scriptText, Object[] args)
at Script.MainPage.OnCounterClicked(Object sender, EventArgs e)4 ) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , UnixFileMode , Int64& , UnixFileMode& , Boolean , Boolean& , Func1 , Func1 ) at System.IO.Strategies.UnixFileStreamStrategy..ctor(String , FileMode , FileAccess , FileShare , FileOptions , Int64 , Nullable1 ) at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream , String , FileMode , FileAccess , FileShare , Int32 , FileOptions , Int64 , Nullable1[[CSScriptLib.RoslynEvaluator, CSScriptLib, Version=4.9.4.0, Culture=neutral, PublicKeyToken=4c30df19402bb442]].CompileCode(String scriptText, String scriptFile, CompileInfo info) at CSScriptLib.EvaluatorBase
```

Contributor guide

Open the contributing guide

Research direction

Open the public MauiDebug repository and Script/Script.sln, then reproduce the failure by pressing the "Click me" button in Android Release mode and compare it with Debug mode. Trace the call from Script.MainPage.OnCounterClicked through CS-Script and Roslyn; done means the same sample runs in Release without the IO_FileNotFound_FileName exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.