locked
How to add dll which is coming from API into blazor RRS feed

  • Question

  • User1018858328 posted

    I will receive a dll from server and i want to add that dll in blazor and execute few functions from javascript. Is there any way to add the dll dynamically in to blazor 

    Wednesday, August 12, 2020 4:00 PM

All replies

  • User475983607 posted

    manikantatpssonata

    I will receive a dll from server and i want to add that dll in blazor and execute few functions from javascript. Is there any way to add the dll dynamically in to blazor 

    Take a look at lazy loading assemblies which will be available in 5.0.

    https://docs.microsoft.com/en-us/aspnet/core/blazor/webassembly-lazy-load-assemblies?view=aspnetcore-5.0

    Wednesday, August 12, 2020 4:08 PM
  • User-474980206 posted

    the lazy loaded dll still needs to be part of the blazor project. It will also need to written to be callable from javascript. the lazy load is to improve startup performance. 

    what is the actual use case you are trying to solve?

     

    Wednesday, August 12, 2020 5:17 PM
  • User1018858328 posted

    Hi Bruce,

    Basically i want to run the blazor in angular application In angular i will receive dll from API in angular application. This is basically to run c# code in web

    Thursday, August 13, 2020 4:17 AM
  • User475983607 posted

    Basically i want to run the blazor in angular application In angular i will receive dll from API in angular application. This is basically to run c# code in web

    You misunderstand the technology.  Blazor and Angular solve the same problem and are not compatible.  You pick either Blazor or Angular not both.

    Thursday, August 13, 2020 10:56 AM
  • User-474980206 posted

    while most WASM toolkits are for building a library callable from javascript, Blazor is not. Mono had a project to build C# WASM libraries, but it appears to be abandoned.

    most WASM toolkits use the clang/LLVM compiler toolchain to create the WASM assembly. mono took this approach for C#. but Blazor took a different approach.

    for Blazor, MS compiled a small .net runtime with clang/LLVM. so the Blazor WASM is a .net runtime, that can host and run .net dll's. this is all orchestrated by javascript, as javascript must load the WASM and fetch and pass the dll's to the Blazor WASM.

    while what you want is doable, load and run generic C# in WSAM, there is no current project (that I know of) for this. It would mostly consist of extracting out the javascript code that loaded the runtime, and dlls out of the blazor javascript support library.  You could request this.

    note: there are several languages you can use to write callable WASM libraries: c/c++, swift, go, rust, kotlin, D, Pascal, and Zig

    if you want to share business logic between the client and server, another option is to switch to node for the server. then you can write the shared logic in typescript. This will also allow server pre-render for the angular app. your micro services can still be C#

     

    Thursday, August 13, 2020 3:32 PM