Blazor Desktop - hybrid Web and Desktop apps in .NET!

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 143

  • @edandersen
    @edandersen  3 ปีที่แล้ว +3

    Any questions let me know in the comments and I will do my best to answer them :)
    Or come ask me direct on Discord! tedstech.com/discord

  • @Susandwyer
    @Susandwyer 3 ปีที่แล้ว +11

    This is what I thought Blazor was when I first heard of it. I kind of skulked away from it when I discovered painfully it was not. But look! now it is. Thank you for sharing your time and knowledge.

    • @edandersen
      @edandersen  3 ปีที่แล้ว +2

      Aw, thanks. Yeah I think this is actual ground breaking stuff

  • @jugs0101
    @jugs0101 ปีที่แล้ว +3

    Exactly what I needed. Thanks very much, 12 minutes was all I required. And thanks for not plastering your face all over everything and continually inserting 'funny' images everywhere to try and 'keep my attention'. 😆

    • @edandersen
      @edandersen  ปีที่แล้ว

      Glad you found it useful! Thanks!

  • @Naster001
    @Naster001 3 ปีที่แล้ว +6

    Very nice video, well explained, concise and the code as reference! Love it!!

  • @bossfly8387
    @bossfly8387 ปีที่แล้ว

    Thank you for this. The boilerplate suggested on Microsoft documentation was driving me nuts. What you laid out for WPF in your github repo is so much better. Subscribed!

    • @edandersen
      @edandersen  ปีที่แล้ว

      Just a word of warning that I don't think this method is supported really, they want you to use MAUI for Blazor in a desktop app I think.

    • @bossfly8387
      @bossfly8387 ปีที่แล้ว

      @@edandersen Sorry did not get you. What method are you referring to?

    • @edandersen
      @edandersen  ปีที่แล้ว

      This 'Blazor Desktop' implementation on my github. It's a hack and isn't what MS is pushing for Blazor-on-Desktop, they want you to use MAUI.@@bossfly8387

    • @bossfly8387
      @bossfly8387 ปีที่แล้ว

      @@edandersen I see ok. I will give it one more shot. My problem was MS docs implementation for wpf was making my navigated components all stack one after the other on the same view instead of each component rendering in its view. Not sure what was going on there.

  • @joseluisdeoliveirasantos9131
    @joseluisdeoliveirasantos9131 3 ปีที่แล้ว +10

    That's the point.
    You've made a very easy maintenance app, very flexible too, for Windows Forms, in less than half hour.
    Thank you by share!

  • @SmoothSkySailin
    @SmoothSkySailin 3 ปีที่แล้ว +1

    Shut up and take my like! I love where Blazor is and where it's going! Thanks for this video!

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Thanks! How about a cheeky sub too? ;-)

    • @SmoothSkySailin
      @SmoothSkySailin 3 ปีที่แล้ว

      @@edandersen done and done!

  • @rpalejiya
    @rpalejiya 3 ปีที่แล้ว

    Very very helpful. Thank you Ted.

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Aw, thanks! Don't forget to like and subscribe ;-)

  • @bienvenidohernandezalmonte4435
    @bienvenidohernandezalmonte4435 3 ปีที่แล้ว +1

    Wow, i need this for Android and iOS

    • @edandersen
      @edandersen  3 ปีที่แล้ว +2

      Yeah - I hope MAUI supports it. An alternative to XAML etc.

  • @YabalTeklebrhan
    @YabalTeklebrhan ปีที่แล้ว

    Can you create a button on the windows application and by pressing can open the blazor web browser

  • @lucasdaquina8282
    @lucasdaquina8282 2 ปีที่แล้ว

    Great stuff dude. Thanks!

  • @CleoCat75
    @CleoCat75 5 หลายเดือนก่อน +1

    Can you make the Windows Forms app a standalone .exe file? Like, JUST the 1 file, where the .EXE contains everything it needs to run?

    • @edandersen
      @edandersen  5 หลายเดือนก่อน +1

      For this technique I really doubt it.

  • @albertngoudjou8581
    @albertngoudjou8581 3 ปีที่แล้ว +6

    Thank you for the video, I have a question regarding the deployment to a client OS for the desktop version. Would the desktop version need a server version or it would run as a standalone application? Another question would it work the same for WPF?
    Thank you

    • @edandersen
      @edandersen  3 ปีที่แล้ว +4

      Yep, runs totally standalone in either WinForms or WPF. The Blazor code runs in the .NET 6 Desktop process. No need for the server/browser version if you don't want it, you can use this for a desktop app only. For a WPF example of this check out the code repo at github.com/edandersen/blazor-desktop-crossplatform-sample

    • @pragmaticprogrammer3397
      @pragmaticprogrammer3397 ปีที่แล้ว

      @@edandersen Will this WPF app run in Linux environment

    • @edandersen
      @edandersen  ปีที่แล้ว

      @@pragmaticprogrammer3397 Nope

  • @wokle7794
    @wokle7794 2 ปีที่แล้ว

    From here, how would I package the winform into exe? And what is the good way to push update to user once released?

    • @wokle7794
      @wokle7794 2 ปีที่แล้ว

      Already found the answer for the 1st question

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Not sure sadly. This is a but of a hack and I wouldn't recommend it now

    • @ItsD-qf7ke
      @ItsD-qf7ke 8 หลายเดือนก่อน

      @@edandersen what would you recommend right now?

    • @edandersen
      @edandersen  8 หลายเดือนก่อน

      I don't have an answer

  • @CyrilGupta
    @CyrilGupta 2 ปีที่แล้ว

    This was pretty cool!

  • @scara1701
    @scara1701 3 ปีที่แล้ว

    Won't the appstate be shared for the users of the Blazor web server app? Only the appstate of the winform app isn't shared.

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Probably. You'll want to set the DI scope to the user somehow on the server version.

  • @glowiever
    @glowiever 3 ปีที่แล้ว +2

    so basically we're embedding an entire browser inside the winform app right? like electron js?

    • @edandersen
      @edandersen  3 ปีที่แล้ว +1

      In a way yes I guess.

  • @sandeshmms
    @sandeshmms ปีที่แล้ว

    is it possible to run the host winform event from blazorwebview?

  • @daniel-lb4bh
    @daniel-lb4bh 3 ปีที่แล้ว

    Very useful, thanks. its great❤

    • @edandersen
      @edandersen  3 ปีที่แล้ว +1

      Cheers, don't forget to like and subscribe! ;-)

  • @not_AI_bot
    @not_AI_bot 2 ปีที่แล้ว

    I am using vs studio 2019, I can't find blazor maui template for vs studio 2019. Give up using blazor, maybe next 2 year

  • @diligencehumility6971
    @diligencehumility6971 2 ปีที่แล้ว +1

    But this is Blazor Server Side. So each time a Windows Client is started up, a SignalR connection is made to the server, and the server pushes the HTML over socket to the client (normally web, but now a web wrapped in a WinForms).
    I don't get the point of this. You want a client side app, to be client side. Why have a client side app, the relies on a live socket connection to the server? -It's not really a client side app.
    Doesn't this approach work with Blazor WebAssembly?

    • @camcommute
      @camcommute 2 ปีที่แล้ว +1

      That's not how it works. The winform app has no connection whatsoever with the Blazor server. The reason is all the razor pages are in the shared library and winform project only have a reference to the shared library and not the web project.

  • @camcommute
    @camcommute 2 ปีที่แล้ว

    Hey! Any ideas on how I can use this approach to prompt the user to access a folder? For example, opening a file system via html input then get the path of the current directory open?
    What I am trying to achieve is for the user to select a directory and from that path pull all the files within that folder and files within sub directory. Any ideas?

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      I'd pop a native dotnet file picker

    • @camcommute
      @camcommute 2 ปีที่แล้ว

      @@edandersen is it possible that when the user clicks on an HTML button to send a click to open the native dotnet file picker?

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      I reckon so. You'd need to use the injection method in the code on github

  • @pheakdeytes5656
    @pheakdeytes5656 2 ปีที่แล้ว

    I use mudblazor as UI library. How can I install it to razor class libray?

    • @camcommute
      @camcommute 2 ปีที่แล้ว

      I was able to use mudblazor with this setup. Works great in both winform and wpf.

  • @iancarr3923
    @iancarr3923 3 ปีที่แล้ว

    Very useful, thanks.

  • @cissemy
    @cissemy 2 ปีที่แล้ว +1

    Great video.
    How can I access database on azure using the desktop ? Should the blazor be wasm or server side ?

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Server side Blazor for database access

    • @cissemy
      @cissemy 2 ปีที่แล้ว

      @@edandersen
      I what should convert to desktop if I want to access to remote data : wasm or server ?

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Server. But when it's a desktop app it doesn't matter

  • @NathenxBrewer
    @NathenxBrewer 3 ปีที่แล้ว

    Can you fire event's from within Blazor's code-behind and trigger something on the parent WinForm?

    • @edandersen
      @edandersen  3 ปีที่แล้ว +1

      Probably! I haven't tried it.

    • @NathenxBrewer
      @NathenxBrewer 3 ปีที่แล้ว

      @@edandersen This would definitely be interesting. That's the easiest way I would think to trigger a notification on the parent form. Also, that opens the door to trigger events for when async events are completed and such.

    • @efcf-gf5uq
      @efcf-gf5uq 3 ปีที่แล้ว +1

      @@NathenxBrewer Yes you can, either by accessing a static class or injecting a service into the dependency container and consuming it in a blazor component

  • @josbexerra8115
    @josbexerra8115 2 ปีที่แล้ว

    Gracias Mistes Teds.... saludos de los andes peruanos

  • @chrisklecker
    @chrisklecker 2 ปีที่แล้ว

    This no longer works as Webview no longer uses windows forms as a base class. The base class is now called WebViewManager. I'm stuck in its usage.

    • @chrisklecker
      @chrisklecker 2 ปีที่แล้ว

      I think the biggest problem I have is that I cannot find the WindowsForms you are installing on my version of VS 2022 nor when I install blazor web forms can I see it on my toolbox.

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Try the github repo linked in the description and see if it works

    • @camcommute
      @camcommute 2 ปีที่แล้ว

      In Form1.cs you need to do serviceCollection.AddWindowsFormsBlazorWebView instead of AddBlazorWebView

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Yeah it's a bit hard to update the video. The linked github repo should be up to date

  • @AKumar1992
    @AKumar1992 2 ปีที่แล้ว

    anyone else getting the error below. I've followed the tutorial twice, closed down visual studio and still getting it:
    Error CS0006 Metadata file \crossPlatformToolbar\BlazorClassLibrary\bin\Debug
    et6.0
    ef\BlazorClassLibrary.dll' could not be found

    • @edandersen
      @edandersen  2 ปีที่แล้ว +1

      Things might have changed since this vid was recorded, check out the linked github repo which I try to keep up to date

    • @camcommute
      @camcommute 2 ปีที่แล้ว

      It's possible there is an error in the share library. Possibly the host.cshtml

  • @jeff.bowman
    @jeff.bowman 2 ปีที่แล้ว

    Would you be willing to share the specs of your dev box? I like the speed I'm seeing.

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Hey. At the time of this vid it was a AMD 5900X CPU, 32GB RAM and a pci-e SSD. Nothing too special :-)

    • @jeff.bowman
      @jeff.bowman 2 ปีที่แล้ว

      @@edandersen Aha. It's that PCIe SSD that makes all the difference. I've got a regular Samsung SSD in my laptop, true, but the whole setup is starting to show its age. It seems there might be a shopping trip in the near future around here 🙂

    • @jeff.bowman
      @jeff.bowman 2 ปีที่แล้ว

      @@edandersen It occurred to me that putting an NVMe SSD into the laptop's SATA slot (adapters are available) wouldn't accomplish much, due to the SATA bottleneck. I think a fella would want an on-board NVMe port. Oh well...

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Yep

  • @artai168
    @artai168 3 ปีที่แล้ว +1

    This kind of desktop app can call the MS Outlook for sending out an email? Or just an web app running on desktop?

    • @edandersen
      @edandersen  3 ปีที่แล้ว +2

      You can call native C# Windows code from Blazor using this method, so should be able to do Outlook stuff

  • @Bogdanjak00
    @Bogdanjak00 2 ปีที่แล้ว

    A very good tutorial. But I have a question. is it possible to build such a solution but using the authorization function on the Blazor side?

    • @camcommute
      @camcommute 2 ปีที่แล้ว

      I think it's possible. You could have a separate web API project that handle this then call it from the shared library

  • @mudmax8974
    @mudmax8974 3 ปีที่แล้ว

    Great video thanks ! I still wonder if this will allow me to program a native app as administrator's use, and on the other hand the web app for users or both native and web have to be the exact same use.

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Quite likely this will be possible :-)

  • @xfer84
    @xfer84 3 ปีที่แล้ว

    Is it possible to do this with a razor pages app?

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Not sure I'm afraid :)

  • @hlzhang346
    @hlzhang346 2 ปีที่แล้ว

    this a good demo

  • @Susandwyer
    @Susandwyer 3 ปีที่แล้ว

    I need to play videos dynamically, in the web view, from my local drive. Is that possible in this setup?

    • @Susandwyer
      @Susandwyer 3 ปีที่แล้ว

      Answer: yes it is, can access html documents on local filesystem with Navigate() method. Unfortunately I have not found a way to do so with the NavigateToString() method.

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      That's great you figured it out :)

  • @klopsquark2323
    @klopsquark2323 2 ปีที่แล้ว

    Nice introduction! Is it possible to implement the same with the built in authentication mechanisms (EF) which can be selected at the Blazor Server project creation screen? It works whenever I start it as a web application. But it throws exceptions in the winforms app. Any suggestions? Thanks...

    • @edandersen
      @edandersen  2 ปีที่แล้ว

      Try one of the MAUI Blazor templates, this method isn't really.supported

  • @ultrarabbit8116
    @ultrarabbit8116 3 ปีที่แล้ว

    How can it be cross platform if Winforms and WPF only runs on Windows?

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Blazor Desktop will support MacOS on MAUI, I just haven't got round to figuring it out yet :)

    • @ultrarabbit8116
      @ultrarabbit8116 3 ปีที่แล้ว

      @@edandersen I see. Thanks for the content. I wonder if you can setup WebView2 on Avalonia Dekstop project and achieve "pure cross platform application" since Avalonia runs on Linux as well.

  • @NathenxBrewer
    @NathenxBrewer 3 ปีที่แล้ว

    Can any data type be used with AppState?

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Yeah pretty much!

  • @nosolocodigos
    @nosolocodigos 2 ปีที่แล้ว

    you should try blazor maui to do the same and more

    • @camcommute
      @camcommute 2 ปีที่แล้ว

      I wanted to use Maui. Got VS 2022 preview and everything then found out that to publish the app you need to sideload it. In doing that requires a sign certificate or Windows won't trust it

  • @adamding3873
    @adamding3873 3 ปีที่แล้ว

    It is interesting. But how do you know it won't be another Silverlight?

    • @edandersen
      @edandersen  3 ปีที่แล้ว +1

      You don't.
      However, Silverlight needed a plugin maintained forever to continue to work. Blazor WASM can run on webassembly in normal browsers forever.
      MAUI is more of a tenuously spiritual successor to Silverlight if you are looking for cross platform Windows/Mac/Web apps, even though its based on Xamarin. XAML etc.

  • @arpanmukhopadhyay3245
    @arpanmukhopadhyay3245 3 ปีที่แล้ว

    Hi Ted, thanks for this video, I was looking for something like this. I have few questions, I have a Windows form app which read / write to registry and create / reads files in disks. I am planning to make the application to multiple OS platforms through Blazor Desktop, will it be possible to access / create native disk files and for Win only OS, read registry... Any help will be appreciated. Thanks

    • @edandersen
      @edandersen  3 ปีที่แล้ว +1

      It should be doable yes :-)

  • @mubarekabdi
    @mubarekabdi 3 ปีที่แล้ว

    Great video. In what scenarios do you think this is useful?

    • @edandersen
      @edandersen  3 ปีที่แล้ว +4

      As an alternative to Electron

  • @jokehuang1611
    @jokehuang1611 3 ปีที่แล้ว

    What's the final .exe size minimum?

  • @rashedmamun3759
    @rashedmamun3759 3 ปีที่แล้ว

    Thank you for this awesome video, I have got an error and I cannot figure it out, the error is like "InvalidOperationException: Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }."

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Check the linked repo for an up to date version :-)

    • @rashedmamun3759
      @rashedmamun3759 3 ปีที่แล้ว +1

      Thanks for your reply, I already found the cause of the error, the favicon.ico was deleted somehow on time of moving the files to the shared project. Thanks again for the video.

  • @ludologian
    @ludologian 2 ปีที่แล้ว

    Hello Ted, I'm unity's c# developer I really like blazor model but as you know c# of unity is so different than .net with the latest c# features. there's no clear route to be professional c# developer .. would you do a tutorial from scratch explaining how to be full stack developer using .net stack woth all goodies they offer like linq , asynchronous programming, lambdas function etc.. I like your style of videos it would be so helpful for other unity developer to get starting with app development. unity's documentation is super easy compared to Microsoft.. if you have any resources please share it with us .. thanks

    • @edandersen
      @edandersen  2 ปีที่แล้ว +1

      Glad you liked it! Best place to start is the official "dotNET" channel :)

  • @mrunalsinhjadeja3937
    @mrunalsinhjadeja3937 2 ปีที่แล้ว

    Is desktop app only run in windows?

  • @omuleanu
    @omuleanu 3 ปีที่แล้ว

    So it will work even if some components require JS interop?

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Yep it still has a full Edge browser instance

    • @mubarekabdi
      @mubarekabdi 3 ปีที่แล้ว

      @@edandersen That's what makes it so interesting ! Full power of desktop plus all the fun staff of the web !! This reminds me the functionalities of web server !

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Yep check out the linked git repo - you can even do WebGL!

  • @wenderitachi
    @wenderitachi 3 ปีที่แล้ว

    Thanks for the video, I have some questions, does it work for a blazor wams project? how is the performance? I have an application with blazor wams but I have problems when rendering many elements, it is possible that this improves when executed from webView

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      I think this is designed for server although the boundary is blurred a bit. Its almost a third Blazor mode. Perf seems fine.

  • @DeepakShaw
    @DeepakShaw 3 ปีที่แล้ว

    Nice Demo

  • @leannekogan
    @leannekogan 3 ปีที่แล้ว

    Can it be used in Windows Store as well?

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      I think so, either with the desktop bridge stuff for UWP in Windows 10 or the normal MSI installer support in the Windows 11 store

  • @bootsector13
    @bootsector13 3 ปีที่แล้ว

    Is this ready for production?

    • @edandersen
      @edandersen  3 ปีที่แล้ว +1

      I believe its supported in Production when .NET 6 is finished :)

  • @kcvinu
    @kcvinu 3 ปีที่แล้ว

    Thanks for the video. Is this possible in VB .Net ?

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      Not sure I'm afraid :)

    • @kcvinu
      @kcvinu 3 ปีที่แล้ว +1

      @@edandersen Um, VB is the second grade citizen in dot net family.

  • @thyssenbot
    @thyssenbot 3 ปีที่แล้ว +1

    Is the performance comparable to a native app? Especially for a UI transition + data heavy app?

    • @edandersen
      @edandersen  3 ปีที่แล้ว +3

      Same performance as a Edge browser - so pretty good. Maybe even better in some cases.

  • @kaplansedat
    @kaplansedat 8 หลายเดือนก่อน +4

    dear pogramming content creators; please dont use mechanic keyboard.

  • @emmanueladebiyi2109
    @emmanueladebiyi2109 3 ปีที่แล้ว

    Nice one!

  • @setiadisudrajat5031
    @setiadisudrajat5031 3 ปีที่แล้ว

    that is cool

  • @bigh1708
    @bigh1708 3 ปีที่แล้ว

    Gidday

  • @dev-qq2vy
    @dev-qq2vy 3 ปีที่แล้ว

    Cool

  • @aisivan
    @aisivan 3 ปีที่แล้ว

    Flutter can do this in less than second

  • @camcommute
    @camcommute 2 ปีที่แล้ว

    For anyone trying this out with latest packages:
    you need to do in (Form1.cs) serviceCollection.AddWindowsFormsBlazorWebView instead of AddBlazorWebView

  • @fallonmassey4714
    @fallonmassey4714 3 ปีที่แล้ว

    I don't get the value here! Blazor, after all this time is still an inferior cross platform solution than Silverlight.
    With Silverlight I could deliver a desktop app that ran on Windows and Mac from ONE set of code, no shared silliness at all.
    I seriously must be missing something.

    • @edandersen
      @edandersen  3 ปีที่แล้ว

      You aren't missing anything.

    • @Qrzychu92
      @Qrzychu92 3 ปีที่แล้ว +4

      You are missing a lot. First of all, the BlazorWebView control can be put into WinForms as above, but also into WPF (which is still windows only), but most improtant, into MAUI. MAUI is coming with .NET 6 and is fully cross platform UI framework.
      So, using Blazor, in one go you can get: a website (server side Blazor), desktop app (both Windows and MacOS), Android and iOS (and iPadOS). All sharing the same CSS, the same languages translations (localization), the same logic, all running multithreaded .NET code.

  • @lancemarchetti8673
    @lancemarchetti8673 2 ปีที่แล้ว

    Egg sil lint !

  • @8359s
    @8359s 3 ปีที่แล้ว

    Debugging this is hell, checked it.

  • @fractalzombie
    @fractalzombie 3 ปีที่แล้ว +1

    I hate your keyboard… it’s have a bad sound, do not use it for video!

  • @gorbulevsv
    @gorbulevsv 3 ปีที่แล้ว

    Cool