structuremap

StructureMap web.config

I have this interface public interface ICartService : IService<Cart> { ... } Implementation of the interface public class CartService : ICartService { public CartService(ICartRepository repository) { _repository = repository; } ... } And in web.config <StructureMap Memento...

Exception Handling with Structuremap

Is there anyway to recover gracefully in an ASP.NET MVC application if the database is not found for some reason when I try to get an instance of my NHibernate Session from Structuremap? public static class StructureMap { private static Configuration Cfg { get { var configuration = new Configuration()...

Using MissingNamedInstanceIs in StructureMap

Hi :) I have this odd problem with StructureMap with regards to using the MissingNamedInstanceIs feature. When doing _containerInstance.GetInstance<T>("key") vs. ObjectFactory.GetNamedInstance<T>("key") I get the following error: StructureMap.StructureMapException : StructureMap Exception Code: 200 Could not find an Instance named "ke...

Does MS PnP Unity Scan for Assemblies Like StructureMap?

In Using StructureMap 2.5 to scan all assemblies in a folder, we can see that StructureMap uses AssembliesFromPath() to explicitly look for types to resolve. What is the equivalent of this in Microsoft Unity? Because Unity is such a generic term, searching for documents about this online is not that easy. Update: Unity has something cal...

StructureMap help needed

How can I rewrite following so that I can do ObjectFactory.GetNamedInstance("MyNHConfiguration") at later time. "Configuration" is in the variable "cfg" under ExposeConfiguration lambda ForRequestedType<ISessionFactory>() .CacheBy(InstanceScope.Singleton) .AddInstances(x => x.ConstructedBy(() => ...

Injecting Subsonic SimpleRepository class to controller

Hi, I'm tryingot get started with IoC, I have an MVC project in which is use subsonic, I'm trying to inject subsonic simplerepository to my controllers but I'm getting this error: StructureMap Exception Code: 205 Missing requested Instance property "connectionStringName" for InstanceKey "60b735fb-0a7f-4eb4-be04-635f6f32233d" Here is my...

Inject static property with StructureMap?

Hi all, is it possible inject static property, like I do below, because it does not work for me? public static IMerchantModule MerchantModule { get; set; } public RequestBaseValidationRules() { MerchantModule = ObjectFactory.GetInstance<IMerchantModule>(); } It works when I inject to non static property. Any ...

.NET Json Serialization Circular Ref Error (Object involves structuremap vars)

I have a web method called from Jquery to display a hierarchical tree object. The return value is a List (Of T) , where T is hierarchical, a parent-child relationship. traversal will be from parent to child. 1) .Net automatically converts the return value from webmethod to JSON to send it back to js client. At that point it throws a ci...

StructureMap/NHibernate Session Per Request including constant transcation

Hi, I just started using StructureMap in my MVC apps, and everything goes fine, excepts handling my ITranscation the correct way. What I want to do is create a new ISession on each request. Together with this I want to start a transcation. On the end of the request I will commit the transcation. My question is, how can I do this the...

How can you inject a session reference

Can you inject a session reference into your class via structure map ...

Using StructureMap to Configure Prism

I'm using Prism and the Unity IoC container that comes along with Prism. However, I'd like to use a different IoC container if that's doable. So; is it? Preferrably I'd like to use StructureMap. Note that I'm not yet familiar with StructureMap, but based on several recommendations I'd like to give it a try. The question is really how t...

Registing Registry using StructureMap

I use StructureMapConfiguration class and add the registry classes to register the components. It's all working file but when I try to do the same across projects within a solution, structureMap starts throwing exception of not being able to find the resistration of the component. Let's say I have two projects. For each project, I add a...

Structuremap (or any IoC, really) architecture question

I'm going to use structuremap for a project I'm working on. The basic gist is that I have a repository pattern with an NHibernate implementation, but I want to use StructureMap to load the repositories in case I ever decide to switch to a Linq2Sql or other type of implementation. I know how to initialize structuremap, but my question is ...

Structuremap instancescope

I have an configuration as follows: ForRequestedType<ISomeInterface>().CacheBy(InstanceScope.PerRequest) .TheDefault.Is.ConstructedBy(x=>x.CacheManager.GetSomeInterface<TestSomeInterface>()); in an ASP.NET application When I look at ObjectFactory.WhatDoIHave(), it tells me: ISomeInterface (Namespace.ISomeInterface) Scoped as : ...

StructureMap - ExplictArguments class usage, issue with multiple constructors

Dear all, I am trying to use StructureMap ExplictArguments class to pass them on runtime and based on them, I want that structure map concludes which constructor should be launched. My test scenario is: public class SpecialClass : ISpecialClass //this is test class, has two constructors { public SpecialClass() { } ...

IOC Container and primatives when creating wrapper

I am trying to create an interface wrapper for my IOC container so I do not have to have a dependency on a particular one. My problem is that some of the service classes I have take in a companyID which is a string. I want to make generic interface methods like T Resolve<T>() where T is the service interface. Right now I use Struc...

Problem - Could not load file or assembly

I was trying to build a social networking site from ASP.NET 3.5 Social Networking book. When I run the code I see the following problems: System.IO.FileNotFoundException: Could not load file or assembly 'Fisharoo.FisharooWeb' or one of its dependencies. The system cannot find the file specified. Source Error: { ...

StructureMap is not reset between NUnit tests

I'm testing some code that uses StructureMap for Inversion of Control and problems have come up when I use different concrete classes for the same interface. For example: [Test] public void Test1() { ObjectFactory.Inject<IFoo>(new TestFoo()); ... } [Test] public void Test2() { ObjectFactory.Initialize( x => x.ForR...

Should Castle DynamicProxy IInterceptor or ProxyGenerator be cached?

I'm using StructureMap to Enrich some of my objects with an instance call to ProxyGenerator.CreateInterfaceProxyWithTarget(myObject, MYInterceptor) Currently I have the MYInterceptor inside my container, should I implement any type of caching for the interceptor? The second question should I register my ProxyGenerator inside my contai...

StructureMap singleton behavior not working

My code is public static class ContainerBootstrapper { public static void BootstrapStructureMap() { ObjectFactory.Initialize(x => x .ForRequestedType<ValueHolder>() .CacheBy(InstanceScope.Singleton) .TheDefaultIsConcreteType<ValueHolder>()); } } In...