Deserialization of interface types is not supported. Type 'Microsoft.JSInterop.IJSInProcessObjectReferece'. (using .NET 8)
First... This is well put together and useful, great job!
The deserialization (not supported) for the specified type I got running your code under a .NET 8.0 version in a Blazor app within an Aspire project. I stop right there and returned back to your provided sample code "KristofferStrube.Blazor.FileSystem.WasmExample" (WE) just changing the "Target framework" to .NET 8.0. Before this I compiled the "KristofferStrube.Blazor.FileSystem" (FS) just changing the "Target framework" to .NET 8.0. The example project just hangs there (I guess it got some unhandled exception). Then I:
- Changed WE to .NET 7, kept FS in .NET 8... IT WORKS.
- Tested WE in .NET 8, FS in .NET 8... just hangs there for eternity.
My next step could be try to figure out what is happening but first I like to see if you can provide a quick answer to this issue.
Hope to hear from anyone soon...
I will need to hear more about what errors you get or some minimal project that reproduces these problems before I can help.
Greatly appreciate the prompt response...
I just used your code, by downloading it and changing both the WE and FS to .NET 8. Nothing else.
I am not adding or changing any other thing of your project. Your thoughts...
When I reproduce the steps you described above, I get the following message in my Developer Console:
Error: Failed to start platform. Reason: TypeError: Cannot read properties of undefined (reading 'dotnet.wasm')
A quick search on Google gives the following as the first result on Stack Overflow: https://stackoverflow.com/questions/77210154/net8-with-blazor-has-an-error-reading-dotnet-wasm
The answer to that issue describes exactly what your problem is. You need to update the Microsoft.AspNetCore packages to an appropriate version that fits your .NET version when upgrading a project.
This is also documented in the official guide for upgrading an ASP.NET Core project from .NET 7 to .NET 8: https://learn.microsoft.com/en-us/aspnet/core/migration/70-80?view=aspnetcore-8.0&tabs=visual-studio
If this is not your problem, then I need a minimal reproducible repository to further troubleshoot this.
Your code works fine in the given solution.
Let me provide the context of the "Deserialization of interface types is not supported. Type 'Microsoft.JSInterop.IJSInProcessObjectReferece'." issue.
Step 1. Create a ".NET Aspire" app with Blazor scaffolding project template as is.
Step 2. Add your libraries to the Blazor App.
Step 3. Create a Page with your sample "DirectoryExplorer.razor" and "ElementExplorer.razor". Just copy the code for those 2 razor files, adjusted the namespace as needed.
Step 3.1 Added route to the "DirectoryExplorer.razor" page.
Step 4. Put a try catch in OPFS line (line 32) as shown below:
protected override async Task OnInitializedAsync()
{
OPFS = await StorageManagerService.GetOriginPrivateDirectoryAsync();
}
Step 5. Debug it... I did add a try - catch to be able to see the issue while calling "GetOriginPrivateDirectoryAsync" and that is where I found the "...interface types is not supported".
Interesting that .NET Aspire with Blazor works very nicely out of the box. Maybe is not a small sample but I like to define where I actually got the error. I tested your File System Access code in the app and it works great.
Again, thanks for your quick responses...
Ah okay. My guess is that the Aspire template uses Server rendering. In-process JSInterop can't be used when using server rendering so you would need to rewrite my samples to not use the InProcess variants of wrapper types. An easy way to make this rewite is to find all the types referenced that contain the words "InProcess" like "IFileSystemHandleInProcess" and then replacing that with "IFileSystemHandle". This will require some more rewrites like using async method instead of certain properties and synchronous methods that are available in the in-process variants.
Thanks for the fast response... I actually started yesterday to do exactly that. I will go this route since you see it as a solution.
Eduardo
On Sun, Jun 23, 2024 at 5:35 PM Kristoffer Strube @.***> wrote:
Ah okay. My guess is that the Aspire template uses Server rendering. In-process JSInterop can't be used when using server rendering so you would need to rewrite my samples to not use the InProcess variants of wrapper types. An easy way to make this rewite is to find all the types referenced that contain the words "InProcess" like "IFileSystemHandleInProcess" and then replacing that with "IFileSystemHandle". This will require some more rewrites like using async method instead of certain properties and synchronous methods that are available in the in-process variants.
— Reply to this email directly, view it on GitHub https://github.com/KristofferStrube/Blazor.FileSystem/issues/6#issuecomment-2185330112, or unsubscribe https://github.com/notifications/unsubscribe-auth/BG2F5NZN24CYOKERELHCWVDZI45SPAVCNFSM6AAAAABJYN2XBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBVGMZTAMJRGI . You are receiving this because you authored the thread.Message ID: @.***>
Kristoffer,
The few modifications went smoothly and all looks good now... Thanks for you support.
Eduardo
On Mon, Jun 24, 2024 at 7:48 AM edam @.***> wrote:
Thanks for the fast response... I actually started yesterday to do exactly that. I will go this route since you see it as a solution.
Eduardo
On Sun, Jun 23, 2024 at 5:35 PM Kristoffer Strube < @.***> wrote:
Ah okay. My guess is that the Aspire template uses Server rendering. In-process JSInterop can't be used when using server rendering so you would need to rewrite my samples to not use the InProcess variants of wrapper types. An easy way to make this rewite is to find all the types referenced that contain the words "InProcess" like "IFileSystemHandleInProcess" and then replacing that with "IFileSystemHandle". This will require some more rewrites like using async method instead of certain properties and synchronous methods that are available in the in-process variants.
— Reply to this email directly, view it on GitHub https://github.com/KristofferStrube/Blazor.FileSystem/issues/6#issuecomment-2185330112, or unsubscribe https://github.com/notifications/unsubscribe-auth/BG2F5NZN24CYOKERELHCWVDZI45SPAVCNFSM6AAAAABJYN2XBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBVGMZTAMJRGI . You are receiving this because you authored the thread.Message ID: @.***>