Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
84 views

Blazor Server - Gracefully handling Circuit disconnects

We’re using a Blazor Server architecture with Lamar as the DI container, registering certain services as scoped to maintain one instance per Blazor circuit. This setup generally works well. However, ...
Matthias Müller's user avatar
0 votes
1 answer
66 views

MassTransit with Kafka and Lamar Exception

I'm running into an issue when I introduce Lamar into my MassTransit project for Kafka when trying to dynamically connect consumer topics at runtime. I have other projects using Azure Service Bus with ...
jaryd's user avatar
  • 871
0 votes
1 answer
114 views

How to get IConfiguration in Wolverine/Lamar ServiceRegistry

I am using Wolverine as my framework of choice. Wolverine comes with Lamar as IoC Container. I have split my container registrations into ServiceRegistries. Now I need to access IConfiguration ...
Luka's user avatar
  • 4,211
0 votes
1 answer
563 views

How to use Lamar with .Net 6 console application

Sorry I don't have any example code. I'm simply trying to find an example of how to use Lamar with a new .Net 6 console application and not finding anything on google. The application is basically ...
geoff swartz's user avatar
  • 5,945
0 votes
0 answers
180 views

Microsoft.Dependency.Injection similar to Lamar For and Use function

I would like to ask about Microsoft.Extensions.DependencyInjection library for IoC implementation. Is there a way to do a similar function for the Lamar library function like services.For<TService&...
Alvin Quezon's user avatar
  • 1,201
3 votes
1 answer
1k views

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 ...
jrn6270's user avatar
  • 179
0 votes
1 answer
212 views

Lamar register service with interface having multiple parameters

Brief Intro - we are using Lamar as IoC container. I am looking for some help to understand how to register a service which implements interfaces with multiple parameters. my interface => interface ...
Anshul's user avatar
  • 75
1 vote
1 answer
403 views

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 ...
Prisoner ZERO's user avatar
2 votes
0 answers
136 views

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, ...
phitch's user avatar
  • 125
0 votes
1 answer
152 views

Conversion to Lamar - Registration - What's the equivalent of this code that uses StructureMap?

I'm migrating an ASP.NET application to .NET5 and have come across the following code that uses StructureMap... For<ICache>().AlwaysUnique().Singleton().HttpContextScoped().Add<RedisCache>(...
inthegarden's user avatar
3 votes
1 answer
1k views

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 ...
onefootswill's user avatar
  • 4,053
0 votes
0 answers
541 views

Lamar with MediatR registering constructor dependencies, is there a better way?

I am using Lamar and i have added a load of dependencies which work in my controllers. When i try to use a handler from MediarR i am having to explicitly set the Ctor dependancies like so: ...
Hawkzey's user avatar
  • 1,153
0 votes
1 answer
496 views

Using the Lamar DI container, how do you build objects with a lambda given a type?

Lamar provides the following syntax for building objects with a lambda: serviceRegistry.For<ISomeType>().Use(x => { ... }); This would allow you to resolve ISomeType which would execute the ...
Derek Greer's user avatar
  • 16.2k
4 votes
1 answer
921 views

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 ...
R4cOOn's user avatar
  • 2,555
0 votes
1 answer
312 views

Lamar AddScoped not working as expected net core webapi

I have netcore webapi project and i'm using Lamar for DI. I have a service MyContextService which i register as scoped public class LifetimeRegistry : ServiceRegistry { public ...
tayab's user avatar
  • 170
0 votes
2 answers
495 views

How can I auto resolve concrete types in Lamar?

The following documentation is not working for multiple reasons: https://jasperfx.github.io/lamar/documentation/ioc/resolving/requesting-a-concrete-type/ First the documentation states that you can ...
Gary Brunton's user avatar
  • 1,930
2 votes
1 answer
5k views

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. ...
William Zink's user avatar
1 vote
1 answer
1k views

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. ...
William Zink's user avatar
1 vote
1 answer
1k views

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:...
Schwammy's user avatar
  • 233
0 votes
1 answer
1k views

Lamar AddInstances with ServiceRegistry

I have a dotnet core website setup with Lamar, I have the following method in Startup.cs public void ConfigureContainer(ServiceRegistry services) { ... } I want to use AddInstances() as described ...
Phil's user avatar
  • 1,779
1 vote
1 answer
645 views

Can we resolve an implementation of an interface that uses other implementations of an interface using Lamar in .NET Core 3?

I'm using .NET Core 3.0 and have the following classes public class DataProviderA: IDataProvider { } public class DataProviderB: IDataProvider { } public class DataProviderCombined: IDataProvider { ...
SamIAm's user avatar
  • 2,451
0 votes
1 answer
274 views

How to debug and find source of the error "NullReferenceException" when bootstrapping C# services using Lamar?

We have some services in our project which we recently ported to .NetCore 3.0. Additionally, since StructureMap is to be sunset, we removed all references and are moving to Lamar since it was the ...
CodeTruthSeeker's user avatar
2 votes
2 answers
2k views

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 ...
João Antunes's user avatar
0 votes
1 answer
1k views

Why won't Lamar inject type of IServiceScopeFactory in ASP.NET Core?

I am trying to implement a health check in an aspnetcore2.2 project which asserts that my Lamar container configuration is valid via IContainer.AssertConfigurationIsValid (essentially that it can ...
Lars Baunwall's user avatar
1 vote
1 answer
496 views

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 ...
Sushant's user avatar
  • 375
2 votes
0 answers
131 views

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 ...
Sushant's user avatar
  • 375
0 votes
1 answer
173 views

Lamar causes 500.30 error when using ServiceRegistry

I am using Lamar as the DI for .Net Core (2.2) Web API. Program.cs public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args)....
Juho Rutila's user avatar
  • 2,458
1 vote
0 answers
352 views

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 ...
Mulciber Coder's user avatar
4 votes
2 answers
2k views

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....
HamedFathi's user avatar
  • 3,959
3 votes
1 answer
618 views

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: ...
soren.enemaerke's user avatar
0 votes
1 answer
673 views

Why after referencing nuget, my packed tool size increased much more comparing with size info provided in nuget.org?

Why is there such huge difference between what I see in nuget.org under package download size and size increase after packing with given nuget? For example: In nuget.org I see that download size of ...
joostas's user avatar
  • 567
0 votes
1 answer
389 views

Scaffolding Entity Framework Controllers with Lamar

I have Lamar set up in my .NET Core 2 project: public class Program { public static void Main(string[] args) { IWebHost webhost = CreateWebHostBuilder(args).Build()...
BM-'s user avatar
  • 616
5 votes
2 answers
1k views

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 ...
Christoph Lütjen's user avatar
0 votes
1 answer
2k views

Lamar IoC Container Setup Issues

I have been attempting to get Lamar working for our dependency injection, but my lack of experience doing so has been causing me some grief. I have a simple dummy controller: [Route("[controller]")] ...
Blankdud's user avatar
  • 698
1 vote
1 answer
2k views

Injecting configuration values in ASP .NET Core 2.1

As with others, I disagree with injecting IOptions into every service that may need it, and looked for other options. My goal was to inject the values needed by the service, and nothing more. I came ...
Eddie T's user avatar
  • 11