Questions tagged [structuremap]

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

structuremap
Filter by
Sorted by
Tagged with
0 votes
0 answers
68 views

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<IMyClass>().LifecycleIs(new ...
JPx's user avatar
  • 1
0 votes
0 answers
470 views

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). ...
Simon's user avatar
  • 5,443
0 votes
0 answers
242 views

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, ...
Eric Brown - Cal's user avatar
0 votes
1 answer
34 views

Override service mapping settings in structureMap

Can I override service mapping for StructureMap settings of added registry: return new Container(x => { For<IService>().Use<OverridenService> x.AddRegistry<...
YMC's user avatar
  • 5,168
0 votes
1 answer
2k views

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 ...
Afraz Ali's user avatar
  • 2,682
0 votes
1 answer
302 views

Structure map calling dispose multiple times when using nested container

Dispose on object instances getting called twice when disposing the nested container at the end of the httprequest. However, controller dispose called once correctly. Below is detailed info on issue. ...
user1424876's user avatar
0 votes
1 answer
661 views

StructureMap 4 constructor dependency with named instance

I want to implement the decorator pattern using StructureMap 4. I've created an interface IDeveloper and two implementations CSharpDeveloper which is the decorated type, and DeveloperDecorator which ...
Sagi's user avatar
  • 9,102
0 votes
1 answer
125 views

No parameterless constructor defined for this object during deploy

The code has DependencyInjection and already have all the required implementation. I am able to run in my machine as well as deploy in a test server. But when it is deployed in client machine where it ...
Martha ngeei's user avatar
0 votes
1 answer
332 views

Structure Map ObjectFactory.GetAllInstances Scope

I've come across some code in the Application_EndRequest event and I'm trying to work out how it will behave: var services = ObjectFactory.GetAllInstances<IService>(); Does this return all ...
Mark Dixon Tech's user avatar
0 votes
2 answers
733 views

how to scan another library with structure map

I have a class library that called ServiceLayer which contains the below code: IProductService.cs public interface IProductService { void AddNewProduct(Product product); IList<Product> ...
kamal's user avatar
  • 237
0 votes
1 answer
32 views

How to coerce using direct class structuremap

I have a problem with writing valid configuration for my classes. Suppose that I Have: interface IA{} class abstract A : IA {} class A1 : A, IA { private readonly IB _ib; public A1(IB ib) ...
MNie's user avatar
  • 1,347
0 votes
1 answer
49 views

StructureMap and classes that cannot accept constructor arguments

I have a ASP.NET web application (not MVC) which is actually a CMS application. I'm trying to set up StructureMap IoC framework and it's working well, but I've now hit a blocker in my understanding. ...
Tom Troughton's user avatar
0 votes
1 answer
1k views

StructureMap - Register a singleton for multiple interfaces

I want to register some animals as singletons, so I wrote a structure map registry with the following code: this.For<ILion>.Use<Lion>().Singleton(); this.For<IElephant>.Use<...
Tho Mai's user avatar
  • 845
0 votes
0 answers
78 views

My class extends from 4 different interfaces. How to register and resolve using Structuremap IoC container

I have 2 class say public class Master : IService public class Settings : ISettings In constructor of Settings class I am calling, var cache = ObjectFactory.GetInstance<IService>(); I am ...
Bhargava Mummadireddy's user avatar
0 votes
2 answers
411 views

SetAllProperties method missing in structuremap Registry

I have a fairly old project that needs some work doing on it, i have run update-package in nuget and now get the following in my TypeRegistry The name 'SetAllProperties' does not exist in the ...
Neil Stevens's user avatar
  • 3,724
0 votes
2 answers
1k views

Windows Azure Error - Could not load file or assembly MFCMIFC80

I have created an Angular/WebAPI/MongoDb project and using StructureMap for dependency injection and I have it published to a private BitBucket account. I have create an Azure Webapp and set it up ...
jkruer01's user avatar
  • 2,195
0 votes
1 answer
214 views

How do I configue StructureMap to create a DbConnection

I have the code below for my Entity Framework context. I am using the overloaded constructor to inject in an in memory database for testing. This works fine but when I use this in my MVC app I need ...
Dave Amour's user avatar
0 votes
1 answer
70 views

Resolve Child class dependency using structure map

I am trying to resolve dependencies using structure map.How do I resolve all child class dependencies automatically by resgitering the base interface using structure map. Conside the following ...
DotNetLearner's user avatar
0 votes
1 answer
113 views

CloudConfigurationManager.GetSetting fails during StructureMap Controller Injection

All of a sudden I started getting the typical Structure Map error stating, "No parameterless constructor defined for this object". This is a common error and usually means that something is wrong with ...
Bayer White's user avatar
0 votes
1 answer
126 views

How to swap StructureMap named instance?

Sample code: public interface IMyClass { string Name { get; set; } } public class MyClass : IMyClass { public string Name { get; set; } } public static class Program { public static ...
Michael Pi's user avatar
0 votes
1 answer
171 views

structuremap configuration asp.net mvc 4

I have a problem with MVC4 StructureMap configuration, when I run the project the compiler fires this error No Default Instance defined for PluginFamily Mace_CrmSystem.Controllers.HomeController ...
Mo Haidar's user avatar
  • 3,915
0 votes
0 answers
241 views

Injecting Session with StructureMap in ASP .Net MVC

I am trying to inject ASP .Net MVC Session into a Controller by providing in interface for it using StructureMap. But StructureMap complaints while trying to do this as HttpContext.Current is not ...
Moon's user avatar
  • 34.3k
0 votes
1 answer
56 views

Specifying a separate injection for a particular interface

Suppose I have the following hierarchy which I wish to instantiate with DI: DatabaseService(IDatabaseRepository) : IDatabaseService Database1Service(IDatabaseRepository) : IDatabase1Service ...
Arithmomaniac's user avatar
0 votes
1 answer
136 views

StructureMap.IContext.RequestedName?

1)IStudyService studyService3 = ServiceLocator.Current.GetInstance(); What would be the StructureMap.IContext.RequestedName in the above call , when we go with empty key? Will it be null or wmpty? ...
user3907595's user avatar
0 votes
1 answer
64 views

IServiceLocator.GetInstance<TService>() is not working

We have an extension method to register the service as shown below we are saying return me the out of proc instance only if the key is remote host name. in detail we expected to receive in proc ...
user3907595's user avatar
0 votes
1 answer
220 views

Conditional and delayed registration on StructureMap

I am registering OwinContext in StructureMap: container.Register(() => HttpContext.Current.GetOwinContext()); But I get the following error on AssertConfigurationIsValid: No owin.Environment ...
Miguel Moura's user avatar
  • 38.1k
0 votes
1 answer
190 views

Trouble Referencing StructureMap.AutoMocking.dll to use RhinoAutoMocker

I've been dying to try out StructureMap's auto mocking container for RhinoMocks per: http://docs.structuremap.net/AutoMocker.htm This documentation states: Out of the box, StructureMap includes ...
jakejgordon's user avatar
  • 4,048
0 votes
1 answer
422 views

Structuremap in MVC5

I'm using structuremap 3.1.2.138 in MVC5. In my IoC-class i'm trying to use the Objectfactory but it states Objectfactory is obsolete and I should use Container but I can't find a way to make this ...
chittybang's user avatar
0 votes
1 answer
682 views

In structuremap, how do I scan assemblies and add all registrations as singletons?

I wish for structuremap to scan my assemblies and register classes as singletons. I'd further restrict this to factories, services etc. For now, however, the challenge is to mark the found ...
Anders Juul's user avatar
  • 2,543
0 votes
0 answers
54 views

Structuremap type mapping

I currently have: var container = new Container(x => { x.For<IService>().Use<Service>().Singleton(); } This replaces all instances of new IService() with new Service(); I also ...
MichaelAttard's user avatar
0 votes
3 answers
395 views

Passing an object to constructor when using StructureMap 3

I have some UserControls in my c# project and use Structuremap 3 as my IoC container, when I want to access the UserControls I use following code: var uc = new UserControlFactory().Create<...
Masoud's user avatar
  • 8,187
0 votes
1 answer
377 views

Using StructureMap 3 in multiple ASP MVC projects

First lets start to describe my project architecture. I have a asp.net mvc application called Portal.Web as startup project and multiple asp.net mvc applications which called Plugin.XXX (Plugin.News, ...
mhesabi's user avatar
  • 1,140
0 votes
4 answers
1k views

Setter injection not working with StructureMap in ASP.NET MVC authorization filter

We use a custom AuthorizeAttribute to handle a few aspects of user authorization. I need to add access to the database to check a value during authorization. This project uses the Repository pattern ...
Phil Figgins's user avatar
0 votes
1 answer
935 views

StructureMap: Pass in runtime arguments to a selected constructor

I want to select a constructor and pass in runtime arguments. I know how I can select a constructor with registry provided arguments and I also know how to provide runtime arguments. But I can’t see ...
Steve Kinyon's user avatar
0 votes
1 answer
1k views

How configure structuremap for fluentscheduler?

I have this structuremap configuration and ITaskFactory for fluentScheduler. public class StructureMapRegistry : Registry { public StructureMapRegistry() { Scan(x => { ...
user3512982's user avatar
0 votes
1 answer
126 views

structure map injection only works in ApplicationController : IController And Not Work in a Class

My Problem With StructureMap Injection From ServiceLayer.Intefaces Of My Project MyProject UI 1.MVC5 WebApplication ServiceLayer 1.interfaces 2.Services DataLayer 1.SiteContext 2.Configuration(...
Pooria Monfared's user avatar
0 votes
0 answers
126 views

Identity 2 RoleStore Error

In my WebApi 2 app I am using StructureMap. The error is being thrown in my ConfigureContainer. The error: There is no implicit reference conversion from Microsoft.Asp.Identity.EntityFramework....
Greg's user avatar
  • 2,652
0 votes
1 answer
227 views

How to use custom factory with Structuremap?

I have a scenario where my class has dependency on two services. However I am using provider pattern and have a custom factory that returns me instances of these services reading from the app.config ...
Afraz Ali's user avatar
  • 2,682
0 votes
1 answer
137 views

StructureMap initialization issue

Currently am using the structure map for injecting the transactionid which is a uniqie Guid that needs to be created each time x.For<ITransaction>() .Use<Transaction>() .Ctor<string&...
Jammy123's user avatar
0 votes
0 answers
178 views

Registering structuremap with open generic types result in error

Open Generic Type public interface ICrudRepository<TEntity, in TKey> where TEntity : class, new() { Implementation public class EmployeeRepository:ICrudRepository<Employee,int> { ...
Deeptechtons's user avatar
  • 11.1k
0 votes
1 answer
67 views

Structuremap won't initialise when ASP.net site is published

I have a .Net 4.0 webforms web app which I use StructureMap for DI. When I debug the site in VS 2013, it works fine, but when I publish the site, it doesn't appear to initialise the ObjectFactory ...
Tom Pickles's user avatar
0 votes
2 answers
2k views

Using TheCallingAssembly or AssembliesFromApplicationBaseDirectory and WithDefaultConditions

Today I have been trying to set up the simplest possible usage of structureMap version 3.1.0.133 in a Windows console app. I'm having trouble getting the WithDefaultConventions method working like I ...
Rakesh Sharma's user avatar
0 votes
1 answer
193 views

Structuremap GetAllInstances returns too many copies

Structuremap 2.6.4.1 In a test I have 3 instances as follows (AHandler, BHandler, CHandler) public class AHandler : ICommandHandler<Event1> {... } These are the only three implementations of ...
George Mauer's user avatar
0 votes
1 answer
1k views

How to register as singleton or transient all types implements one interface with StructureMap

I have two interfaces that says if a service have to be singleton or transient: public interface ITransient {} public interface ISingleton {} I implement this interfaces in other interfaces and ...
Javier Ros's user avatar
  • 3,651
0 votes
2 answers
534 views

What is best way to pass injections to base controller when using C# StructureMap.Mvc5?

What is best way to get injections in base controller when using C# StructureMap.Mvc? I can think of these 2 ways and don't know which is better. From controller arguments to base controller ...
Sandeep Kumar's user avatar
0 votes
1 answer
118 views

Can't get structuremap working with MVC5

I've created a default MVC5 web application in Visual Studio 2013, and added in the StructureMap.MVC5 package from NuGet. I've created an interface ITester and an implementation Tester, and my ...
Cocowalla's user avatar
  • 14k
0 votes
1 answer
61 views

Integration test with Bounded DbContexts

I'm using multiple DbContext(Bounded DbContext) in my application. So I have following codes: public class EfUnitOfWork<TContext> : IUnitOfWork where TContext : BaseDbContext, new() { ... } ...
Masoud's user avatar
  • 8,187
0 votes
1 answer
72 views

strucutreMap Dependency injection is not working

In my application i configured structuremap like public class DefaultRegistry : Registry { #region Constructors and Destructors public DefaultRegistry() { Scan( ...
Binson Eldhose's user avatar
0 votes
1 answer
211 views

Structuremap cause StructerMapConfigurationException("Operation could destabilize the runtime") only on some machines

I'm using Structuremap 3.0.2.115 as my IoC container and defined following Factory class to get the Usercontrols in my WinForm application(with .NET 4): public class UserControlFactory { public T ...
Masoud's user avatar
  • 8,187
0 votes
1 answer
425 views

Custom Singleton LifeCycle with expiry time using StructureMap

Can we create a Custom LifeCycle using StructureMap wherein the object has to be in Singleton scope for specified preiod of time, after which the object has to be created again. In short, can we ...
Krishna Desiraju's user avatar

1
29 30
31
32 33
35