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
0
votes
1 answer

StructureMap could not load assembly from file in a plugin framework

I'm using StructureMap to load Plugins at the start of my application. At application startup, when I create the container I do a simple scan like: internal static IContainer Init() { var container = new Container(a => { a.Scan(scan…
Jeff Sheldon
  • 2,074
  • 1
  • 14
  • 23
0
votes
2 answers

IoC StructureMap resolve named instance

For the following code how would I resolve based on the name? public interface IService {} public class ServiceA : IService {} public class ServiceB : IService {} public class ClassA { public IService service { get; set; } public…
ShaneKm
  • 20,823
  • 43
  • 167
  • 296
0
votes
1 answer

Unity to Structuremap help

I am trying to convert this code in my DI mapping from Unity to Structuremap but I cannot seem to get it to work. I am using Repository pattern like the one in found in shrinkr by Kazi Manzur Rashid found here http://shrinkr.codeplex.com/ Any help…
Paul
  • 12,392
  • 4
  • 48
  • 58
0
votes
1 answer

How to override Structuremap registry in integration tests for Asp.Net MVC

I am writting UI Integration tests/Acceptance tests for a MVC website. I want to be able to override the repository classes at run time for these tests with my InMemory repository classes. I am using Structuremap default configuration and the thing…
Afraz Ali
  • 2,672
  • 2
  • 27
  • 47
0
votes
0 answers

How to specify what named service instance to inject into a controller with StructureMap

Microsoft Unity DI offers a feature where you can register multiple objects for the same interface and give them a name. Then in your constructor you can use an attribute with the argument to specify by name which object you want to inject. I am…
Chris Putnam
  • 884
  • 1
  • 10
  • 16
0
votes
1 answer

StructureMap and logical call contexts

I have a peculiar problem with StructureMap. Whenever I construct an object, that spawns a new thread, the logical Call context (System.Runtime.Remoting.Messaging.CallContext) becomes empty: class Program { static void Main(string[] args) { …
Lars Baunwall
  • 75
  • 1
  • 4
0
votes
0 answers

StructureMap3 session-scoped singleton - no session variable?

I'm fairly new to StructureMap. I'm trying to create a session-scoped singleton class (using MVC4 with Sitecore). After some googling i came up with this: x.For().LifecycleIs(new HttpSessionLifecycle()).Use(); Issue is that…
0
votes
0 answers

Getting the current WebAPI request in IDependencyResolver

I am using StructureMap as my IoC container in a WebAPI project. I want to provide different implementations of certain dependencies based on values in the request (query string or http headers). StructureMap has the concept of Profiles for this,…
Simon
  • 5,373
  • 1
  • 34
  • 46
0
votes
0 answers

what is the effect of a lock on a static object in a web applicaiton on iis 8

we are having some issues with nhibernate in an MVC asp.net web app, One of our first theories was that since session is not thread safe, that might be causing our issue. we are using structure map, and our session wrapper is instantiated as a…
Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97
0
votes
1 answer

Override service mapping settings in structureMap

Can I override service mapping for StructureMap settings of added registry: return new Container(x => { For().Use x.AddRegistry(); For().Use
YMC
  • 4,925
  • 7
  • 53
  • 83
0
votes
1 answer

Using ASP.NET MVC 2, StructureMap, Fluent NHibernate, and PostgreSQL

I am using the above combo in a new web app Im doing just to try to learn to build new stuff to expand my knowledge. Im hoping to go live if I do a good job.. Im kind of new at MVC and the other products so I was trying to find a link to a good…
0
votes
1 answer

how to use `.ForSingletonOf<>` in StructureMap

Why when I use .ForSingletonOf() the result of messagebox is false public static class IoC { public static void InitIoC() { ObjectFactory.Configure(config => { …
Mohamad Shiralizadeh
  • 8,329
  • 6
  • 58
  • 93
0
votes
1 answer

Structuremap 3 Single Interface Multiple Types

I have a an ASP.NET MVC 5 app, I am using Structuremap 3 as the IOC. I have an Interface which is used in multiple types through the N-Tier and I cannot find a succinct explanation of how to to map multiple types to the same interface for automatic…
Csharper
  • 53
  • 2
  • 10
0
votes
1 answer

How to use TinyMessenger (Event Aggregator) With DI Container

I was searching for a lightweight Event Aggregator for .Net and I stumbled upon TinyMessenger (https://github.com/grumpydev/TinyMessenger/wiki). It does seem to do the job that I want but I cannot figure out how to use it with a DI container e.g…
Afraz Ali
  • 2,672
  • 2
  • 27
  • 47
0
votes
2 answers

NServicebus share nested container with WebAPI dependency scope

Is it possible to share/use the nested container created by the WebAPI dependency resolver? The structuremap.web (I'm using structuremap and NServiceBus.StructureMap and UseContainer(x => x.ExistingContainer(container))) package…
Simon Fox
  • 10,409
  • 7
  • 60
  • 81