structuremap

StructureMap, IIS 7.5 and FileIOException

Howdy all. I am trying to solve a problem which is apparently not uncommon and I'm not sure how to find how this was resolved for folks. When I run StructureMap on my machine through IIS I get an exception and it looks like this: **Description**: The application attempted to perform an operation not allowed by the security policy. To g...

StructureMap: Programmatically retrieve list of instance keys from StructureMap.config

I've defined a for a specific interface within my StructureMap.config. There can be many different available concrete types defined. I would like to programmatically retrieve a list of available instance keys (names) that are currently available without actually parsing the StructureMap.config file itself. Is there any way to do this?...

Set Inner Dependency by Type using Structuremap

I have a structuremap configuration that has me scratching my head. I have a concrete class that requires a interfaced ui element which requires an interfaced validation class. I want the outer concrete class to get the default ui element, but get a concrete-class-specific validation object. Something like this: class MyView { IProm...

StructureMap Configuration Per Thread/Request for the Full Dependency Chain

I've been using Structuremap for a few months now, and it has worked great on some smaller (green field) projects. Most of the configurations I have had to set up involve a single implementation per interface. In the cases where I needed to choose a specific implementation at runtime, I created a factory class that used ObjectFact...

StructureMap - Insert Dependency upon Demand

Hi there, i'm trying to make my exceptionhandling dependend on the context. I have a factory class constructing exceptionhandlers. the handler should be constructed by the last thrown exception type. configuring structuremap the classic way, it works out fine. trying to use conditional constructing, my code fails and i can't see why?! W...

Having trouble with Dependency Injection and ASP.NET MVC

Hi folks, I've got a greedy constructor defined for my Controllers. Each controller requires an ILoggingService instance. Now my dependency injection (which is StructureMap .. but if you don't use that, please keep reading) works fine .. but I wish to make it that the ILoggingService greedy constructor requires a String. This value will...

StructureMap "WithCtorArg" "EqualTo" and nullable types

StructureMap doesn't like passing in Nullable types as constructor arguments. Is there a reason for this? Is there a way to get this to work? [TestMethod] public void Demo() { ObjectFactory.Initialize(x => x.ForRequestedType<TestClass>() .TheDefault.Is.OfConcreteType<TestClass>() .WithCtorArg("param1").EqualT...

Array Constructor Dependency With StructureMap

I've some ITask concretes types defines in my TaskRegistry : public class TaskResigstry : Registry { public TaskResigstry() { ForRequestedType<IBootstrapperTask>().TheDefaultIsConcreteType<StartTasks>(); ForRequestedType<ITask>().TheDefaultIsConcreteType<FirstTask>(); ForRequestedType<ITask>().AddConcret...

What version of StructureMap can I use in webform app (Net 2.0)

Hi Guys, I am bit confuse. I would like to use StructureMap in my webform app, but it is still Net 2.0. I am not really sure which version I should use. Anyone using StructureMap for Net 2.0 project? Which version? Thanks for any response. X. ...

StructureMap Application Sample

I would like to know where I could find a sample C# application written using StructureMap. Can anyone point me in the right direction? ...

NServicebus Message Handler Lifecycle in IOC StructureMap

What is the required IOC instance lifecycle I need to use in conjuction with a NServiceBus message handler if I want an instance per message handled. PerRequest won't work, since given the numerous constructor dependenices and dependency graph I have, it gives me many instances when I require only one per Handle(MessageX msg) call. I ca...

Can StructureMap load modules/assemblies on demand?

Are there facilities in StructureMap that will allow me to load services from other modules (assemblies) on demand like it's done in Unity? ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor) and another like this=>InsertJCDC(fakeBox). When I stub out the parent I want to return fakePor. But when I run the code it returns...

What's the best way to inject different implementations of the same interface in to a controller using StructureMap?

I am fairly new to StructureMap, but my understanding is that there are two ways of getting an instance from the ObjectFactory: By type (i.e. ObjectFactory.GetInstance<IFoo>()) By type and name (i.e. ObjectFactory.GetNamedInstance<IFoo>("foo.bar")) I have seen a multitude of examples out there demonstrating how to create an MVC Contr...

Inject AutoMapper

I have been working on injecting AutoMapper into controllers. I like the implementation of Code Camp Server. It creates a wrapper around AutoMapper's IMappingEngine. The dependency injection is done using StructureMap. But I need to use Castle Windsor for my project. So, how do we implement the following dependency injection and set-up u...

Appropriate Situation for Using IoC Container?

Let's say I have a common WCF service and console app project that do not change across client specific deployments. I have some interfaces in the common projects that are implemented by specific client code. The client code obviously changes from client to client. I'm thinking this would be an appropriate use for an IoC container. In my...

StructureMap (or any IoC) and WCF

Where would one bootstrap StrucureMap in a WCF service? Completely lost here at the moment.... ...

StrucutureMap RhinoMock Record/Playback, Example needed

I'm looking for some examples on how to do the following Mock Tests using StructureMap or Unity with NUnit. I have the following code structure public interface IDAL { List<Model> Method1(int id); } public class DAL : IDAL { public List<Model> Method1(int id) { List<Model> retval = new List<Model>(); DbComman...

IOC with multiple databases that use same interface (StructureMap or any other DI Framework)

We've been experimenting with StructureMap, and I'm having trouble grasping how to handle situations where a single interface has multiple implementations. The code below shows an example where we have two databases that are both accessible from a single service. public class SomeController : Controller { private ISomeService _servi...

Where should I store a reference to my DI container?

I'm wondering how I should store/reference my dependency injection container(s). Is it alright to have a container be a static property on a static class? Or should I have the container be an instance variable on the application? I'm wondering what the pros and cons of each option are, and what is the best practice for this in web, mvc, ...