1

I see that there is support for ASP.NET Core 3.0 but what about 3.1? I've tried with no luck. Not sure if I am doing something dumb or if it is not supported?

I've installed the latest Nuget Packages:

  • Lamar 4.0.0
  • Lamar.Microsoft.DependencyInjection 4.0.2

And I am using:

var builder = new WebHostBuilder();
builder.UseLamar()

The file includes using Lamar.Microsoft.DependencyInjection; at the top.

But getting error: 'WebHostBuilder' does not contain a definition for 'UseLamar'.

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
Schwammy
  • 223
  • 3
  • 15

1 Answers1

2

The Integration with ASP.Net Core guide includes a note that states:

If you are targeting .Net Core 3.0 and/or netstandard2.1, use the newly consolidated HostBuilder instead of the previous IWebHostBuilder.

A literal replacement for the code shown in the question would look like this:

var builder = new HostBuilder();
builder.UseLamar();

However, the typical setup code for creating a host builder, with a call to UseLamar added, would look something like this for 3.0+:

Host.CreateDefaultBuilder(args)
    .UseLamar()
    .ConfigureWebHostDefaults(webHostBuilder =>
    {
        webHostBuilder.UseStartup<Startup>();
    });

The note I called out above links to the ASP.NET Core docs, which explains the generic host in much more detail: .NET Generic Host.

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
  • Kirk, that got me pretty close. I had to add .Build().Run() to the end to make it run: Host.CreateDefaultBuilder(args) .UseLamar() .ConfigureWebHostDefaults(webHostBuilder => webHostBuilder.UseStartup()).Build().Run(); – Schwammy Jan 02 '20 at 14:06