structuremap

IoC, Dll References, and Assembly Scanning

Although this question is related to StructureMap, my general question is: When wiring up components with an IoC container in code (as opposed to configuring via xml) do you generally need explicit project/build references to all assemblies? Why the separate assemblies? Because: "Abstract classes residing in a sepa...

Structuremap Stackoverflow Exception

I keep getting a stackoverflow exception when I call "GetInstance" (the last line). All, yes ALL of my types implement ITracker. MultiTracker has a constructor with a single parameter, which is an array of ITracker's. It seems like StructureMap is ignoring the fact that I told it that MultiTracker is the default class I want when reques...

Where in your solution do you typically put your StructureMap Registry classes?

Here's the current layout: Solution: Core Domain Interfaces DataAccess Providers Session Service UI UnitTests IntegrationTests I typically try to keep my core domain entities / POCOs as light as possible without very many external dependencies.. So I was thinking it might make sense to put it in the Service layer as it typical...

Real open source project that uses Structuremap?

Hi I want to learn structuremap and how to arrange/structure my DI code, Are there any open source project that uses StructureMap that I can look at for guidance? ...

MVP pattern using webforms and DI object instantiation

I am using the generic repository pattern to persist my data. On the PageLoad, I am creating a new Repository (from IRepository) object, and on PageUnload, I dispose of it. Should the MasterPage/Page be in charge of instantiating the objects to pass to the presenter or should the presenter be in charge of this? I'm more concerned wi...

ASP.NET MVC: HTTPContext and Dependency Injection

Hello, Currently I have an ActionFilter that gets the current users name from HttpContext and passes it into the action which uses it on a service method. eg: Service.DoSomething(userName); I now have a reason to do this not at the action level but the controller constructor level. Currently I'm using structure map to create contro...

StructureMap: Is there a way to get a non-static container?

All examples of StructureMap that I've seen use the static ObjectFactory class to initialize and resolve objects. I however would like to pass around a reference to my container. I assume that ObjectFactory is just a singleton wrapper for a non-static object. But where is it? ...

Function stubbed out with Structuremap Automocking not returning value

Using Josh Flanagans StructureMap Automocking overview, I'm trying my hand at it but can get the following code to return the Category object I've assigned: [Test] public void Service_Should_Return_Category_From_ID() { // Arrange var categoryToTest = new Category() { ID = 1, Name = "Department 1", Description = ...

StructureMap Interceptors

I have a bunch of services that implement various interfaces. eg, IAlbumService, IMediaService etc. I want to log calls to each method on these interfaces. How do I do this using StructureMap? I realise this is pretty much the same as this question it is just that I am not using windsor. ...

In StructureMap, how can I change the InstanceScope at runtime?

In my DefaultRegistry I have this configuration: ForRequestedType<INHUnitOfWork>().CacheBy(InstanceScope.HttpContext) .TheDefault.Is.OfConcreteType<NHibernateUnitOfWork>(); At some point in the web application flow I want to change the InstanceScope to HttpSession to obtain a long conversation, so I do this: PluginTypeConfigu...

Issues with my MVC repository pattern and StructureMap

I have a repository pattern i created on top of the ado.net entity framework. When i tried to implement StructureMap to decouple my objects, i kept getting StackOverflowException (infinite loop?). Here is what the pattern looks like: IEntityRepository where TEntity : class Defines basic CRUD members MyEntityRepository : IEntityReposito...

Dependency injection for Silverlight?

I normally use StructureMap.dll (from MvcContrib) for dependency injection in .NET. Is there an equivalent for Silverlight, or any tools anyone uses? I can do it by hand, obviously, and it's not difficult. But I wondered if there was something formalised like StructureMap but for Silverlight. ...

StructureMap controller factory and null controller instance in MVC

I'm still trying to figure things out with StructureMap and one of the issues i'm running into is my Controller Factory class blowing up when a null controller type is passed to it. This only happens when the application builds for the first time, after which every subsequent build works fine. Even when i shutdown Visual Studio and reope...

Having problems with ASP.NET MVC and StructureMap.

Hi folks, I've got StructureMap working fine on my machine. Everything works great ... until I request a resource that doesn't exist. Instead of a 404, i get a 500 error. eg. http://localhost:6969/lkfhklsfhskdfksdf Checking the net, i was told to fix my structuremap controller class. Did that and joy! i now get the -original default 4...

Structuremap and profiles

I am using Structuremap in ASP.NET project and I am using ObjectFactory.Profile = "Mock"; to force the use of a mock further down the system and that all works out fine. But changing the profile, Will that change of profile affect all requests to my system or only for the current request? How can I change the profile in structuremap...

How Do I Use the MoqAutoMocker that comes with StructureMap 2.5.3?

I'm trying to use the MoqAutoMocker class that comes with StructureMap and I can't find any examples of how it should be used. All I have to go on is the example at the StructureMap site that uses RhinoMocks. What I'm trying to do is get reference to one of my auto-mocked/injected dependencies using the Get method. According to that l...

What is the Best Way to Organize a ASP.Net MVC Solution Using Dependency Injection?

I am early in development on a new ASP.Net MVC project and I using this project to get into DI. I'm pretty sure that I am going to go with Structure Map, but that isn't what I am asking about. What I am trying to figure out is how best to organize my solution. Do both the unit test project and the model get a configuration file to map th...

How can I configure Structuremap to auto scan type in Assembly and Cache by Singleton?

I am using mvc.net with StructureMap to scan and register all repositories and services for me. Now I want to register and cache by Singleton. How can I do? Thanks... IContainer container = new Container(x => { // Register Repositories and Services x.Scan(y => { y.AssemblyContainingType<SomeRepos...

StructureMap : EqualToAppSetting with non string constuctor argument

Given public class Blah : IBlah { public Blah(decimal argument) { } } When ForRequestedType<IBlah>() .TheDefault.Is.OfConcreteType<Blah>() .WithCtorArg("argument") .EqualToAppSetting("argument_app_setting_key") Then StructureMap throws the following exception No Default Instance defined for PluginFamily Sy...

StructureMap EXception

Hi Guys, I am getting this error while creating the object using structureMap. The actual error is "Expected file structuremap.config can't be opened at location". But I can see the config file at that location. I don't know what im missing. ...