首页 > 解决方案 > DotVVM 2.0 - 无法运行试用 Business Pack 控件

问题描述

我已经使用 Visual Studio 创建了一个 DotVVM Core 2.0 项目,并且我已经激活了我从私人订阅源添加到该项目中的 Business Pack 试用版。我已经在 ConfigureServices 的 DotvvmStartup.cs 中注册了 Business Pack。我在 IntelliSense 中看不到 bp 控件,当我尝试使用 bp 控件运行 Web 应用程序时,我收到一个错误,即 tagprefix 未注册。

我使用最新版本的 Visual Studio 2017 Community 和最新版本的 DotVVM 和 Business Pack。感谢您的任何建议。

标签: dotvvm

解决方案


也许你不会调用 method DotvvmStartup.ConfigureServices。这是由 VS2017 扩展模板(v2.0.118.0 及更低版本)和 dotnet CLI 模板(dotvvm.templates.2.0.3)中的“错误”引起的。

请检查Startup.ConfigureServices

  public void ConfigureServices(IServiceCollection services)
  {
      ...
      services.AddDotVVM(); //this line is incorrect
  }

您应该替换services.AddDotVVM()services.AddDotVVM<DotvvmStartup>(); https://github.com/riganti/dotvvm/blob/master/src/DotVVM.Framework.Hosting.AspNetCore/ServiceCollectionExtensions.cs#L17

这将创建实例DotvvmStartup并调用方法DotvvmStartup.ConfigureServices
DotvvmStartup 对象被创建 2 次(services.AddDotVVM<DotvvmStartup>()app.UseDotVVM<DotvvmStartup>(env.ContentRootPath))。


推荐阅读