Questions tagged [lamar]

Lamar is a new OSS library written in C# that is a new IoC container meant to replace the venerable, but increasingly creaky StructureMap library.

Lamar was purposely designed and built to maximize compliance with the underlying IoC behavior assumed by ASP.Net Core. To reduce friction in Lamar usage, Lamar directly implements the core ASP.Net Core abstractions for dependency injection.

36 questions
5
votes
2 answers

How to pass argument at runtime?

We're migrating from StructureMap to Lamar but I could not find the "Lamar version" for passing arguments at runtime. We have a class that requires a string argument (pseudo code): public class MyRepository { public MyRepository(string accountId)…
Christoph Lütjen
  • 5,403
  • 2
  • 24
  • 33
4
votes
1 answer

Inject different implementions in Controller based on Route

I've got an ASP.NET Core application and I'd like to use different strategies based on the Route selected. As an example if someone navigates to /fr/Index I want to inject the French translation implementation into my Controller. Likewise when…
R4cOOn
  • 2,340
  • 2
  • 30
  • 41
4
votes
2 answers

How to use Lamar 2 with ASP.NET Core 3 preview?

I configured Lamar with ASP.NET Core 3 but I got an error System.InvalidCastException: 'Unable to cast object of type 'Microsoft.Extensions.DependencyInjection.ServiceCollection' to type 'Lamar.ServiceRegistry'.' My config in Program class: …
HamedFathi
  • 3,667
  • 5
  • 32
  • 72
3
votes
1 answer

Injecting Runtime Objects Using Lamar

I'm trying to build a package for Lamar for a framework which I maintain. To show what I mean by reference to StructureMap, the relevant method which was able to mix a runtime object with Service abstractions is (where the container is passed in to…
onefootswill
  • 3,707
  • 6
  • 47
  • 101
3
votes
1 answer

Lamar alternative to StructureMap Forward()

In StructureMap you could declare a Forward<,> statement, that would allow for registering a single concrete instance to be resolved by multiple interfaces from the StructureMap documentation: var container = new Container(_ => { // Let's make…
soren.enemaerke
  • 4,770
  • 5
  • 53
  • 80
2
votes
1 answer

Can't get Lamar (IOC) to resolve API Controller Dependencies in .NET Core 3.1

I am getting an error when trying to call the controller below using Lamar to resolve the dependencies at runtime. I have tried .AddControllersAsServices() and without and still get the same result. Using ASP.NET Core: 3.1 Lamar…
2
votes
2 answers

Proper way of registering 3rd party DI Framework (Lamar/Autofac) on Azure functions V2

Azure Functions V2 now supports .net dependency injection In order to achieve that you need to do the following code: [assembly: FunctionsStartup(typeof(MyNamespace.Startup))] namespace MyNamespace { public class Startup : FunctionsStartup …
2
votes
0 answers

How wan we Inject dependency while registering ServiceRegistry

I wanted to call one static class in which I need to pass IConfiguration, which will get called on startup static class stay in Infrastructure layer I don't want to add a reference in the main application Startup.cs public class Startup { public…
Sushant
  • 375
  • 1
  • 2
  • 5
1
vote
1 answer

When and how to create presenters using windows forms with MVP and dependency injection

This is a question regarding dependency injection (DI) using Lamar, with windows forms (C#) using the model-view-presenter (MVP) pattern and how (and when) to initialize presenter objects. I have a solution split up into three…
jrn6270
  • 61
  • 11
1
vote
1 answer

Why is my Lamar Constructor Selection Configuration failing

I have a custom component with its own Migrations, DbContext & UnitOfWork. I'm trying to upgrade it to use EF Core & Lamar. THE GOAL: 1. When people don't pass-in DbContextOptions...configure using the defaults in OnConfiguring 2. When people…
Prisoner ZERO
  • 13,848
  • 21
  • 92
  • 137
1
vote
0 answers

Using Oakton to check my Lamar configuration for net5 core application and getting null reference, how do I troubleshoot this?

I am setting up this diagnostic to assist in Mediator Pipeline Behavior issue where my ValidationBehavior is not being called. Below is the hostbuilder setup which is used to configure Lamar, MassTransit, and Serilog: public static IHostBuilder…
phitch
  • 115
  • 9
1
vote
1 answer

StructureMap -> Lamar .NET Core 3.1 service creation not working

I am trying to migrate from StructureMap to Lamar (4.1.0) on the latest dotnet core release (3.1) This project worked before the switch to Lamar, but so much has changed I am getting a touch lost. Question? After the scan occurs, how can I create an…
1
vote
1 answer

Getting error: 'WebHostBuilder' does not contain a definition for 'UseLamar'

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…
Schwammy
  • 223
  • 3
  • 15
1
vote
1 answer

How to map two different Interface such that one Interface value get change automatically other should get reflected

I have Core in which Interface is declared as public interface IRequestProvider { int SomeId { get; set; } } Implementation also define in same layer and then I have another layer Repo layer in which I am calling another…
Sushant
  • 375
  • 1
  • 2
  • 5
1
vote
0 answers

How do you use Lamar as the IOC in NancyFx inside an ASP.NET Core web-application?

I'm building an ASP.NET Core REST Service. So far, I have a (working) ASP.NET Core (2.2) web-application that I have altered to use a Lamar IOC. It works beautifully. I now want to add Nancy(fx) to this application, because, I REALLY want my…
1
2 3