作者:手机用户2502863567 | 来源:互联网 | 2022-12-06 16:50
我正在尝试添加视图到我的ASP.NET核心MVC项目,我收到一个错误.
错误消息是
There was an error running the selected code generator:
'Value cannot be null.
Parameter name:path'
该视图将用于ViewComponent.
我的步骤是
Right click ->
Add View ->
Type View Name ->
Uncheck 'Use a Layout Page' ->
Template : Empty ->
Click Add.
我搜索了一下,但找不到任何结果.
编辑:
这是一个Startup.cs
namespace Udemy.MvcWebUI
{
public class Startup
{
// This method gets called by the runtime. Use this method to add
//services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddDbContext(optiOns=> options.UseSqlServer(@"Server=localhost\SQLEXPRESS;Database=Events;
User Id=sa;Password=Omurcan.1994;"));
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseFileServer();
app.UseNodeModules(env.ContentRootPath);
app.UseMvcWithDefaultRoute();
// db tanimi icin
using (var serviceScope = app.ApplicationServices.GetService().CreateScope())
{
var cOntext= serviceScope.ServiceProvider.GetRequiredService();
context.Database.EnsureCreated();
}
}
}
}
我该如何解决?
谢谢你的帮助.
1> TanvirArjel..:
Microsoft.VisualStudio.Web.CodeGeneration.Design
您的项目可能缺少包裹!
Microsoft.VisualStudio.Web.CodeGeneration.Design
根据您的项目.NET Core版本安装正确版本的nuget包.
然后,如果您最近从任何较低版本将项目更新到.NET Core 2.1,那么也将项目的包更新到最新版本.
然后不要忘记下载 .NET Core SDK 的最新稳定版本(2.1.500)并安装在您的计算机上.
希望你的问题能够得到解决!