小编Sig*_*gge的帖子

使用blazor加载外部.NET Standard 2.0程序集

在Blazor应用程序中,我想加载外部程序集并执行方法。为此,我使用Blazor模板创建了一个新的ASP.Net Core Web应用程序。

然后,在Razor页面(将由浏览器/ wasm编译并执行)中,我使用反射来加载程序集并运行方法(基于此处找到的代码)

// download external assembly from server
HttpClient client = new HttpClient();
var bytes = await client.GetByteArrayAsync("http://localhost:62633/_framework/MyCustomLib.dll");

//load assembly
var assembly = System.Reflection.Assembly.Load(bytes);

// get type/method info
var type = assembly.GetType("MyCustomLib.MyCustomClass");
var method = type.GetMethod("WriteSomething");

// instantiate object and run method
object classInstance = Activator.CreateInstance(type, null);
method.Invoke(classInstance, null);
Run Code Online (Sandbox Code Playgroud)

由于blazor / mono.wasm的优点,该方法WriteSomething包含一个Console.WriteLine()可在浏览器的控制台中打印内容的代码。该库中的完整代码为:

namespace MyCustomLib
{
    public class MyCustomClass
    {
        public void WriteSomething()
        {
            System.Console.WriteLine("This is printed from a loaded dll 3 …
Run Code Online (Sandbox Code Playgroud)

c# webassembly asp.net-core .net-standard blazor

6
推荐指数
1
解决办法
873
查看次数

如何在ASP.NET Core中实现angular 4服务器预渲染

我正在将一个ASP.NET Core项目从AngularJS升级到Angular 4.现在Angular Universal(社区分支)已经集成到Angular本身,我想尝试服务器预渲染.

使用Vue 2和ASP.NET Core进行预渲染非常优雅(例如http://mgyongyosi.com/2016/Vuejs-server-side-rendering-with-aspnet-core/).

是否有关于将Angular 4服务器预渲染与ASP.NET Core 集成的类似示例或教程,避免从Angular Universal样本进行任何重构?

prerender asp.net-core angular4

4
推荐指数
1
解决办法
6540
查看次数