I'm trying add view to my ASP.NET Core MVC project and I'm getting an error.
The error message is
There was an error running the selected code generator:
'Value cannot be null.
Parameter name:path'
The view is going to use for ViewComponent.
My steps are
Right click ->
Add View ->
Type View Name ->
Uncheck 'Use a Layout Page' ->
Template : Empty ->
Click Add.
I searched about it but can't find any result.
EDIT :
Here is a 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<IUsersService, UsersManager>();
services.AddScoped<IUsersDAL, EFUsersDAL>();
services.AddScoped<IUsersInfoService, UsersInfoManager>();
services.AddScoped<IUsersInfoDAL, EFUsersInfoDAL>();
services.AddScoped<IEventTypesService, EventTypesManager>();
services.AddScoped<IEventTypesDAL, EFEventTypesDAL>();
services.AddScoped<IEventsService, EventsManager>();
services.AddScoped<IEventsDAL, EFEventsDAL>();
services.AddScoped<ICityService, CityManager>();
services.AddScoped<ICityDAL, EFCityDAL>();
services.AddScoped<IDistrictService, DistrcitManager>();
services.AddScoped<IDistrictDAL, EFDistrictDAL>();
services.AddDbContext<EventContext>(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<IServiceScopeFactory>().CreateScope())
{
var context = serviceScope.ServiceProvider.GetRequiredService<EventContext>();
context.Database.EnsureCreated();
}
}
}
}
How can I fix it ?
Thanks for your help.
May be Microsoft.VisualStudio.Web.CodeGeneration.Design
package is missing in your project!
Install the correct version of Microsoft.VisualStudio.Web.CodeGeneration.Design
nuget package according to your project .NET Core version.
Then if you recently updated your project to .NET Core 2.1 from any lower version then update your project's packages to latest version also.
Then don't forget to Download the latest stable version (2.1.500) of .NET Core SDK and install on your machine.
Hope your problem will be solved!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With