dotnet / MobileBlazorBindings

Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
MIT License
1.21k stars 172 forks source link

.NET 6 support? #423

Closed BenMakesGames closed 2 years ago

BenMakesGames commented 2 years ago

MBB works with .NET 5, but when I upgrade to .NET 6 rc 2, I get the following exception:

image

will MBB work with .NET 6 when it's released?

Eilon commented 2 years ago

There is a PR to update MBB to .NET 6 but it is not yet merged and I have not had a chance to review it yet either. MBB in general shouldn't work at all on .NET 5 because Xamarin.Forms doesn't run on .NET 5 as far as I know.

Either way, .NET 6 support will eventually land!

BenMakesGames commented 2 years ago

I've been using .NET 5 with MBB since I first discovered MBB. seems to work fine. (I do update the Xamarin nuget packages... maybe that's all it takes?)

BenMakesGames commented 2 years ago

in case anyone reads this and thinks "oh, yay, I can use .NET 5", I wanted to add that I have recently encountered issues using .NET 5 when using shared component libraries! until I added a component library, I was getting away with .NET 5 everywhere; having added a component library, I've had to downgrade (some) projects to .NET Core 3.1.

dcuccia commented 2 years ago

@BenMakesGames good to know. Interested to know the limitations (haven't tried). Was direct "Add Link" code sharing of components an alternative option?

Xyncgas commented 2 years ago

I want blazor mobile bindings. If it means running blazor without a browser, we can finally embrace one UI but entirely on .NET. Nowadays I have problems with blazor being single threaded and is slow to evolved due to it being blocked on webassembly and browser developments, my product doesn't need the browser and it shouldn't, what I wanted was cross platform in the first place I mean heck even if you say web has links and navigations and how great webassembly is I can still make my application working by publishing a nerfed version of my app to the web and have users to download my actual ones and in my application I can still have my own CMS without the web.

BenMakesGames commented 2 years ago

@dcuccia I didn't try that option; I haven't even heard of it until now :P I'll look into it and try it out today as soon as I get into work!

@Xyncgas what I'm about to say is probably a matter of opinion: I don't see an issue with requiring the browser. it's being used as a rendering engine, which for me feels like a perfect use of an available tool. browsers have been around for longer than many other rendering engines, and have matured a lot. CSS is also very powerful, and when it's still not good enough, we have SCSS. finally, from a business point of view, it's much easier to come by a web designer than a Xamarin or WPF designer.

I agree that the single-threaded architecture of Blazor is a little awkward to work with, but it's only technically required by WASM, which Blazor Desktop doesn't use. I've been using Reactive.NET and Tasks to do some parallelization, but I haven't actually tested that these are truly running on separate threads; I merely assume they are... something else I can look into today at work, perhaps :P

Eilon commented 2 years ago

Blazor, like most UI technologies (WPF, WinForms, native Windows UI, browser UI, and most other UI platforms), is single-threaded for UI operations. That is, changing the UI itself must be done on the UI thread. But you can have other threads for doing other work, as well as using async patterns (that doesn't necessarily cost you any threads).

BenMakesGames commented 2 years ago

thanks for the clarification. I assumed the UI was single-threaded because it made working with WASM easier (I had read something to that effect, I thought). but I guess it doesn't matter either way: other logic is free to be multi-threaded!

BenMakesGames commented 2 years ago

@dcuccia I'm not sure I know what you mean by direct/"add link" sharing of components. are you referring to adding file links to a project, instead of adding another project to the solution?

dcuccia commented 2 years ago

@BenMakesGames yes, was referring to referencing/building the components themselves in multiple projects vs a lshared library dependency (may not fit your req's)

BenMakesGames commented 2 years ago

@dcuccia I played around with it a little more, creating a minimal project demonstrating the issue, and I believe it actually has to do with using Microsoft.AspNetCore.Components.Web 5.x, instead of Microsoft.AspNetCore.Components.Web 3.x.

it's my understanding (from instructions online) that a component library must explicitly reference Microsoft.AspNetCore.Components.Web. I had probably tried using 5.x at first, since I was generally using .NET 5.

in my minimal project, I happened to link 3.1.20 (since that's what the application I'm developing is now using; I just copied its .csproj as a base for the minimal test project), and everything was working. confused that everything was working, I tried upgrading packages, and when I bumped Microsoft.AspNetCore.Components.Web up to 5.x, I started having issues.

I think there's some deeper understanding about these various packages that I lack, but which would allow me to easily see what's going on here if only I understood them :P but from this intermittent "just playing around" that I've been doing, I now believe (but need to test more) that you can generally use .NET 5 with MBB, as long as you use Microsoft.AspNetCore.Components.Web 3.x. I won't be able to do any more investigation today, but I'll continue to play with this throughout the week, and let you know if I find anything new :P

BenMakesGames commented 2 years ago

wanted to post to say that I successfully re-upgraded my MBB project to .NET 5, and then to .NET 6, with the following caveats:

I have been able to upgrade some other packages to 6.x, including System.DirectoryServices (but nothing exciting, like EF, which also results in a variation on the above error message).