-
Notifications
You must be signed in to change notification settings - Fork 383
Description
I'm encountering an issue when generating a dump in my .NET MAUI Blazor Hybrid application on .NET 8 using the Microsoft.Diagnostics.NETCore.Client library. When the app runs on Windows, it works as expected, but when running on Android, I receive the following error:
My code:
public async Task WriteDumpAsync()
{
string appDataDirectory = FileSystem.AppDataDirectory;
string timestamp = DateTime.UtcNow.ToString("yyyyMMdd_HHmmss");
string fileName = $"dump_{timestamp}.dmp";
string dumpPath = Path.Combine(appDataDirectory, "dumps");
int processId = Process.GetCurrentProcess().Id;
DiagnosticsClient client = new DiagnosticsClient(processId);
if (!Directory.Exists(dumpPath))
Directory.CreateDirectory(dumpPath);
DumpType dumpType = DumpType.Normal;
// Attempt to write the dump
await client.WriteDumpAsync(dumpType, Path.Combine(dumpPath, fileName), logDumpGeneration: false, CancellationToken.None);
}
Result on android:
Microsoft.Diagnostics.NETCore.Client.ServerNotAvailableException: Unable to connect to Process 28258. Please verify that /data/user/0/com.companyname.androiddumpgeneration/cache/ is writable by the current user. If the target process has environment variable TMPDIR set, please set TMPDIR to the same directory. Please see https://aka.ms/dotnet-diagnostics-port for more information
at Microsoft.Diagnostics.NETCore.Client.PidIpcEndpoint.GetDefaultAddress(Int32 pid)
at Microsoft.Diagnostics.NETCore.Client.PidIpcEndpoint.GetDefaultAddress()
at Microsoft.Diagnostics.NETCore.Client.PidIpcEndpoint.ConnectAsync(CancellationToken token)
at Microsoft.Diagnostics.NETCore.Client.IpcClient.SendMessageGetContinuationAsync(IpcEndpoint endpoint, IpcMessage message, CancellationToken cancellationToken)
at Microsoft.Diagnostics.NETCore.Client.IpcClient.SendMessageAsync(IpcEndpoint endpoint, IpcMessage message, CancellationToken cancellationToken)
at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.WriteDumpAsync(DumpType dumpType, String dumpPath, WriteDumpFlags flags, CancellationToken token)
at AndroidDumpGeneration.Components.Pages.Home.WriteDumpAsync() in C:\Users\davic\OneDrive\Documentos\GitRepositories\net-maui-android-dump\AndroidDumpGeneration\Components\Pages\Home.razor:line 49
at AndroidDumpGeneration.Components.Pages.Home.GenerateDumpAsync() in C:\Users\davic\OneDrive\Documentos\GitRepositories\net-maui-android-dump\AndroidDumpGeneration\Components\Pages\Home.razor:line 25
To verify directory access, I tried writing a simple .txt
file to the /data/user/0/com.companyname.androiddumpgeneration/cache/
directory from my application, and it succeeded. This confirms I have write permissions to that directory. Given that I can write files there, it suggests that the issue might be related to the dump generation library on Android rather than a permissions or environment configuration problem
Steps to Reproduce
- Clone and open the AndroidDumpGeneration project.
- Run the application to an Android device or emulator.
- Navigate to the home page.
- Click the Generate Dump button.
- Observe the error displayed on screen.
Expected Result:
The dump should be generated successfully on Android.
Actual Result:
A runtime error occurs, and the dump is not generated.
Configuration
- Target: .NET 8.0 Android
- Tool/Library: Microsoft.Diagnostics.NETCore.Client version 0.2.553101
- IDE: Visual Studio 2022
- OS: Android (Emulator or Device)
- Host Machine: Windows 11 x64
Repository that demostrates the issue:
https://github.com/davicbaba/net-maui-android-dump