OYIon / LiveSharp

Public repository for the LiveSharp project
96 stars 4 forks source link

Does LiveSharp work with the WebAssembly Hosted template? #78

Closed devantler closed 4 years ago

devantler commented 4 years ago

I just bought a subscription, but I can't figure out how to make LiveSharp work with a WebAssembly application using the hosted template. Is this possible, and if so how?

I've tried with a combination of both:

<PackageReference Include="LiveSharp" Version="1.5.39" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.5"/>

In my Server and Client project, but without any success. Only including the two references in the Server project works, but then client updates are not updated in real-time.

ionoy commented 4 years ago

Hi @niem94

Are you running the LiveSharp server? Do you see any messages appearing when application starts?

devantler commented 4 years ago

LiveSharp reports i need to add

<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.5"/>

to make blazor webassembly applications work with LiveSharp.

When I add the LiveSharp package to the server and the client, it requires the SignalR package to both, but when I add the SignalR package to the client csproj, the application won't boot correctly.

I will find the logs later (or tommorow) and share, but my thought is I should be able to add the LiveSharp package to both the client and the server, and only add the SignalR package to the server, as it is the server that boots the client app in the hosted template.

Edit: Yes I am running the newest version of LiveSharp Server installed as a global dotnet tool.

devantler commented 4 years ago

This is the build time error I get when adding LiveSharp to the Client project while having both the LiveSharp package and the SignalR package added to the Server project:

Custom error : Please install 'Microsoft.AspNetCore.SignalR.Client' NuGet package to use LiveSharp with Blazor Web Assembly [/Users/nikolaidamm/Repos/business-uml-creator/Client/BusinessUMLCreator.Client.csproj]

This is the runtime error I get in the browser when adding the LiveSharp package and the SignalR package to both the Client and Server project:

image

It should be noted the app works just fine without LiveSharp, or with LiveSharp only enabled on the Server and other projects that are not the Client.

warappa commented 4 years ago

With LiveSharp 1.5.45 and Microsoft.AspNetCore.SignalR.Client 3.1.6 (Server and Client) I don't experience this issue - it works.

devantler commented 4 years ago

With LiveSharp 1.5.45 and Microsoft.AspNetCore.SignalR.Client 3.1.6 (Server and Client) I don't experience this issue - it works.

Thanks, I'll test it out 🙂

devantler commented 4 years ago

It does not work on my end yet. It might be that LiveSharp does not work with Fluxor, as the error I get points to that.

Is support for Fluxor (https://github.com/mrpmorris/Fluxor) something you can solve on your end @ionoy? If not feel free to close the issue.

devantler commented 4 years ago

It seems this way of finding implementations is what LiveSharp does not like:

builder.Services.AddFluxor(options => options.ScanAssemblies(currentAssembly));

Behind the surface it uses:

public static IServiceCollection AddFluxor(this IServiceCollection serviceCollection, Action<Options> configure = null);
ionoy commented 4 years ago

Hi @niem94

Could you create a small sample project that I could use to reproduce the issue?

devantler commented 4 years ago

@ionoy yes, i'll make it sometime this week 🙂

devantler commented 4 years ago

@ionoy here is a sample where the error occurs. https://github.com/niem94/livesharp-sample

I hope it is of use to you 🙂

ionoy commented 4 years ago

@niem94 thanks for the sample!

To be honest, I'm not sure what's going on. As soon as I reference LiveSharp in the Client project, it adds a System.Private.CoreLib dependency which to my understanding should only be referenced in .NETCore projects. I'd be happy if somebody could help me understand what is going on here.

Without Luxor it works fine, because there isn't any code that would touch System.Private.CoreLib. Actually LiveSharp also scans the assemblies, but it can handle exceptions while doing so.

I checked Fluxor code, and I think it would be possible to wrap Assembly.GetTypes() in a try/catch clause. The code in question is located here: https://github.com/mrpmorris/Fluxor/blob/master/Source/Fluxor/DependencyInjection/DependencyScanner.cs#L21

image

devantler commented 4 years ago

@ionoy ill try to send this to the maintainer, to see if this is something he/she can fix, or to get more knowledge thereof. Thanks for taking the time to try and make it work on your end :-)

StevenTCramer commented 4 years ago

LiveSharp does NOT work with Blazor-State either for the same reason. Hopefully, we can find a fix soon.

ionoy commented 4 years ago

This issue has been fixed in 1.5.63