If you are a web developer and are developing for a browser, then you are sure know JS, which can be executed inside a browser. There is an opinion that JS is not very suitable for complex calculations and algorithms. And although in recent years JS has made a big breakthrough in performance and wide of use, many developers continue to dream of launching a system language inside the browser. In the near future, the game may change thanks to WebAssembly. Microsoft is not standing on place and actively trying to port .NET to WebAssembly. As one of the results, we received a new framework for client-side development - Blazor. It is not quite clear yet whether Blazor can be faster than modern JS frameworks like React, Angular, Vue due to WebAssembly. But it definitely has a big advantage - development in C # as well as the whole .NET Core world can be used inside the application. Compiling and running C# in a browser The process of compiling and executing such a complex language as C # is a complex and time-consuming task. Is it possible to compile and execute C # inside the browser? However, Microsoft, as it turned out, had already prepared everything for us. After that, you need to install Nuget package for analyzing and compiling C #. Let's prepare the start page. First you need to parse the string into an abstract syntax tree. Since in the next step we will be compiling the Blazor components, we need the latest ( LanguageVersion.Latest ) version of the language. For this, Roslyn for C # has a method: Already at this stage, you can detect compilation errors by reading the parser diagnostics. Next, compile Assembly into a memory stream. Note that you need to get the references - list of the metadata of the connected Assemblies. But reading these files along the path Assembly.Location did not work, because there is no file system in the browser. Perhaps there is a more effective way to solve this problem, but the goal of this article is a conceptual possibility, so we download these libraries again via Http and do it only when we first start compiling. From EmitResult you can find out if the compilation was successful, as well as get diagnostic errors. Now we need to load Assembly into the current AppDomain and execute the compiled code. Unfortunately, there is no possibility to create several AppDomain inside the browser, so it is safe to load and unload Assembly . At this stage, we compiled and executed C # code directly in the browser. A program can consist of several files and use other .NET libraries. Is not that great? Now we need to fo deeper. Compiling and running Blazor Components in a browser Blazor components are modified Razor templates. To compile the Blazor component, you need to create a whole environment for compiling Razor templates and set up extensions for Blazor. You need to install the Microsoft.AspNetCore.Blazor.Build package from nuget. However, adding it to our Blazor project will not work, because then the linker will not can to compile the project. Therefore, you need to download it, and then manually add 3 libraries. Create engine to compile Razor and modify it for Blazor, since by default the engine will generate Razor code for the pages. Only the fileSystem is missing for execution - it is an abstraction over the file system. We have implemented an empty file system, however, if you want to compile complex projects with support for _ViewImports.cshtml , then you need to implement a more complex structure in memory. Now we will generate the code from the Blazor component, the C # code. From doc you can also get diagnostic messages about the results of generating C# code from the Blazor component. Now we got the code for the C# component. You need to parse SyntaxTree , then compile Assembly, load it into the current AppDomain and find the Type of the component. Same as in the previous example. It remains to load this component into the current application. There are several ways to do this, for example, by creating your RenderFragment . Conclusion We compiled and launched the Blazor component in the browser. Obviously, a full compilation of dynamic C# code right inside the browser can impress any developer. But here it is necessary to take into account such "pitfalls": To support two-way bindings, bind needs additional extensions and libraries. To support async, await , similarly connect extension libraries Compiling nested Blazor components will require a two-step compilation. All these problems have already been solved and this is a topic for a separate article. GIT: https://github.com/BlazorComponents/CompileBlazorInBlazor Demo: https://blazorcomponents.github.io/CompileBlazorInBlazor/