Blazor.FileSystemAccess icon indicating copy to clipboard operation
Blazor.FileSystemAccess copied to clipboard

Feature: Support Blazor Server

Open ollih1980 opened this issue 3 years ago • 4 comments

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.'

ollih1980 avatar May 02 '22 07:05 ollih1980

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 avatar May 02 '22 07:05 KristofferStrube

@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}

ollih1980 avatar May 02 '22 07:05 ollih1980

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.

KristofferStrube avatar May 02 '22 07:05 KristofferStrube

Okay.. Thanks a lot!

ollih1980 avatar May 02 '22 07:05 ollih1980

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.

KristofferStrube avatar Nov 10 '22 16:11 KristofferStrube