Questions tagged [structuremap]

StructureMap is a Dependency Injection / Inversion of Control tool for .NET licensed under Apache 2.

StructureMap is a Dependency Injection / Inversion of Control tool for .NET licensed under Apache 2. It can be found at https://structuremap.github.io/.

Installation

StructureMap can most easily be installed through its NuGet package.

Install-Package structuremap

Links

Related

1728 questions
7
votes
2 answers

Structuremap Disposing of DataContext object

I wanted to be sure if structuremap will dispose my DataContext after per request ends. Here is my setup ForRequestedType().TheDefault.Is.OfConcreteType(); SelectConstructor(() => new…
Petrick Lim
  • 287
  • 4
  • 13
7
votes
1 answer

StructureMap .Net Core Windows Service Nested Containers

There are lots of articles talking about how to use Structure Map with ASP.NET Core, but not very many talking about console applications or windows services. The default behavior in ASP.Net Core is that StructureMap creates a Nested Container per…
jkruer01
  • 2,175
  • 4
  • 32
  • 57
7
votes
1 answer

How to use StructureMap Registry to Configure EF Core in Separate Project?

I'm trying to set up a solution in Visual Studio that has all of the EF Core files in one project (Infrastructure), separate from my ASP.NET Core web project. Further, I want to prevent developers from accidentally using types from the…
ssmith
  • 8,092
  • 6
  • 52
  • 93
7
votes
1 answer

StructureMap and injecting IEnumerable

I'm new to StructureMap and have some existing code that I'm working with that uses StructureMap 2.5.4. There is a class that is constructed using StructureMap that has a constructor that takes IEnumerable as a parameter. The registry has the…
John Mills
  • 10,020
  • 12
  • 74
  • 121
7
votes
0 answers

How To Override StructureMap 3 Plugin Mapping

We are using StructureMap 3.1.6.186 and are running into a problem with overriding a particular plugin. In our case, we have a console application which we are deploying to a remote server. The Console application has a very distant dependency on an…
jakejgordon
  • 4,008
  • 7
  • 36
  • 45
7
votes
2 answers

StructureMap returns a disposed nHibenrate session object from thread local scope

[OR] How to define a StructureMap life cycle for UoW to be consumed by http requests and quartz jobs I have this web application which uses SM for IoC. I am using HybridHttpOrThreadLocalScoped scope to store my nHibernate ISession objects. This…
kaptan
  • 3,060
  • 5
  • 34
  • 46
7
votes
1 answer

Injecting a factory method using StructureMap

I'm using a wrapper for the ASP.NET Membership provider so that I can have more loosely coupled usage of the library. I'm wanting to use StructureMap to provide true IoC, but I'm having trouble with configuring it with a User-to-Profile factory…
James Kolpack
  • 9,331
  • 2
  • 44
  • 59
7
votes
1 answer

StructureMap causes Stack Empty exception in Web API Help Pages ModelDescriptionLink.cshtml

I have a Web API project which uses StructureMap for its DI. It's been working fine for awhile, but I'm having some issues with the Web API help pages (Microsoft.AspNet.WebApi.HelpPage) where InvalidOperationExceptions are being thrown as a result…
Zout
  • 821
  • 10
  • 18
7
votes
1 answer

StructureMap throws ArgumentNullException on HttpContext

I'm having a very weird issue with StructureMap.MVC5 I created a brand new MVC5 project in Visual Studio (default options for an ASP.net MVC project were left selected.) I then installed structuremap.mvc5 via the nuget package manager…
Sk93
  • 3,676
  • 3
  • 37
  • 67
7
votes
3 answers

How can I implement NHibernate session per request without a dependency on NHibernate?

I've raised this question before but am still struggling to find an example that I can get my head around (please don't just tell me to look at the S#arp Architecture project without at least some directions). So far I have achieved near persistance…
Ben Foster
  • 34,340
  • 40
  • 176
  • 285
7
votes
1 answer

StructureMap: How to register the same instance for all its interfaces

StructureMap newbie question. public class SomeClass: IInterface1, IInterface2 { } I would like the following test to pass: Assert.AreSameInstance( container.GetInstance(), container.GetInstance()); How would I…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
7
votes
2 answers

Structure Map parameterless constructor error

I am trying to set up structure map ver 3.0.5.0 with Web API 2. I have followed this implementation: Configuring dependency injection with ASP.NET Web API 2.1 However, I am getting this error when doing a get against my ComplexesController: An…
Greg
  • 2,654
  • 3
  • 36
  • 59
7
votes
1 answer

structuremap Web Api 2 Account Controller and individual accounts

I pretty New at IOC and web-api 2, but have got StructureMap to work on my own Controllers in web-api 2. What I don't have managed is to use StructureMap on the AccountController using Individual Accounts. I use AccountController out of the Box, and…
Roger
  • 71
  • 2
7
votes
1 answer

StructureMap Exception Code 205 Missing requested Instance property

I'm trying out the latest build of StructureMap, to learn about IoC containers and the like. As my first test, I have the following class: public class Hospital { private Person Person { get; set; } private int Level { get; set;…
Jason Evans
  • 28,906
  • 14
  • 90
  • 154
7
votes
1 answer

Can Structuremap DefaultConventionScanner find non-public classes

I have just started using StructureMap, having previously worked with Spring.Net. I love the DefaultConventionScanner and the ability to scan assemblies and use convention over configuration to find classes. But there seems to be a limitation that…
Colin Desmond
  • 4,824
  • 4
  • 46
  • 67