Blazor.FileSystemAccess
Blazor.FileSystemAccess copied to clipboard
Feature: Support Blazor Server
Hello,
I'm getting a Error while trying to open a Directory Dialog.
protected async Task SetExcludeFoler()
{
try
{
var options = new DirectoryPickerOptionsStartInWellKnownDirectory() { StartIn = WellKnownDirectory.Pictures };
directoryHandle = await FileSystemAccessService.ShowDirectoryPickerAsync(options);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
if (directoryHandle != null)
{
string folderName = directoryHandle.Name;
}
}
}
Exception : Microsoft.JSInterop.JSException: 'An exception occurred executing JS interop: Deserialization of interface types is not supported. Type 'Microsoft.JSInterop.IJSInProcessObjectReference'. Path: $ | LineNumber: 0 | BytePositionInLine: 1.. See InnerException for more details.'
Hey @ollih1980, Thanks for the issue. :)
First of all is this in Blazor WASM or Blazor Server?
Second, could you try to run it in debug mode so that I can see the Inner Exception?
Best regards Kristoffer
@KristofferStrube its "Blazor Server" and inner exception is:
InnerException | {"Deserialization of interface types is not supported. Type 'Microsoft.JSInterop.IJSInProcessObjectReference'. Path: $ | LineNumber: 0 | BytePositionInLine: 1."} | System.Exception {System.NotSupportedException}
The package does not currently support Blazor Server as I use the InProcess version of the IJSObjectReference to get values like the Name synchronously.
I will leave this issue open as a milestone to support Blazor Server in a future release.
Okay.. Thanks a lot!
This was fixed as a part of #28 and has been published in version 2.0.0 to NuGet.
We now have a sample project that shows how to use the package in Blazor Server. https://github.com/KristofferStrube/Blazor.FileSystemAccess/tree/main/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample
There are some limitations though like not being able to read very big files in Blazor Server.