Questions tagged [structuremap]

0

votes
0

answer
8

Views

StructureMap: how to report problems

Suppose I have an object that is itself declared as StructureMap registry but I forgot to add some dependencies to its list so the object cannot be built. For some reason, this does not manifest at all in any logs. How such debug information can be viewed?
Askar Ibragimov
1

votes
2

answer
76

Views

Defining an 'HttpClient' singleton via StructureMap causes an error about 'HttpMessageHandler' being not configured in runtime

Trying to define an HttpClient singleton in StructureMap ala: For().Singleton().UseIfNone(); This results in the following error in runtime (upon dependency injection): StructureMap.StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type...
XDS
0

votes
0

answer
3

Views

Scoping StructureMap Container to Maintain DbContext Correctly

My application uses StructureMap for dependency injection. It is a large application...and after looking at PerfMon stats...it seems StructureMap is creating a LOT of instances of the DbContext. As such, I am trying to ensure the SAME instances are created across all classes...but no matter what...
Prisoner ZERO
1

votes
1

answer
32

Views

RhinoAutoMocker Testcase fail due to Method Attribute

I have an interface public interface IMyInterface { [CustomAttribute] void MethodA(); } and the corresponding class implementing it public class MyClass: IMyInterface { public void MethodA() { // } } I am using StructureMap.AutoMocking, when I create a Test case : var mocker = new Rhino...
knowdotnet
1

votes
1

answer
233

Views

Structuremap - dependency injection - EF Core DBContext lifetime per request

Has anyone had any luck setting up an EF Core DBContext with Structuremap 'correctly' (what is correctly?) DBContext needs to be a singleton across the lifetime of the request. I understand that the default lifecycle is Transient. I understand that that will get a nested container, which effectively...
jenson-button-event
1

votes
1

answer
1.1k

Views

StructureMap error - no default instance is registered

I have a console demo app using StructureMap IoC container. The demo has all the interfaces and implementation all in one file in one project and the scanning registry looks like the following: public class ConsoleRegistry : Registry { public ConsoleRegistry() { Scan(scan => { scan.TheCallingAssembl...
Rod
1

votes
0

answer
29

Views

Structure map automatically resolve instance by name

My problems is that I want to register two types for one interface: I've checked this articles: https://groups.google.com/forum/#!msg/structuremap-users/2T_WTAjRVJ8/HKsELqJEOi4J https://groups.google.com/forum/#!topic/structuremap-users/75-1AV1boMw For().Singleton().Use().Named('pageManager'); Fo...
mihkov
1

votes
0

answer
84

Views

Structuremap interception of Controllers

I'd like to use AOP to intercept calls to all methods within ASP.NET Controllers and ApiControllers. Following http://structuremap.github.io/dynamic-interception/ I tried to get it to work as follows. The interceptor at present does nothing much, but provide a way to see the method name and its attr...
user9314395
1

votes
0

answer
87

Views

How to select a constructor by ExplicitArguments type in StructureMap?

I have the class Foo with 3 constructors where each of them has 2 parameters. public class Foo { public string Location; public Foo(IContainer container, DefaultData data) { Location = 'DefaultData'; } public Foo(IContainer container, DbData data) { Location = 'DbData'; } public Foo(IContainer conta...
Dominic Jonas
1

votes
1

answer
31

Views

StructureMap recursion using constructor injection

I need to figure out how to inject an implementation of an interface into itself. As by the example below where I would like to use the add method recursively. A simple interface with an add function public interface IRecursiveFactory { int Add(int number, int max = 10); } Injected into the DI conta...
Eric Herlitz
1

votes
0

answer
33

Views

Single App consuming multiple IoC registries and has conflicts

I have a single application that talks to separate databases through two individual UnitOfWork classes. I am using StructureMap to build my classes. Individually, each one builds and runs correctly. However, once I consume both container registries within my 'Web Application', I get conflicts. Both...
Court N
1

votes
1

answer
16

Views

Activation error occurred while trying to get instance of type IBackupTableStorageService, key “” StructureMap library

I am facing issue of mapping. My solution is as below. I have two projects 1. Azure Function (v1) project with Framework: .Net Framework 4.7.2 2. Class Library with Framework: .Net Framework 4.7.2 In 1st project i have an azure function which is triggering using Queue and call my fun...
Ashish Jain
1

votes
0

answer
30

Views

StructureMap interceptor and DynamicProxy

I am trying to upgrade StructureMap from 2.6 to 4.7. I had an interceptor which creates and return proxy. public object Process(object target, IContext context) { Type targetType = target.GetType(); var instanceRef = _container.Model.AllInstances.FirstOrDefault(e => e.ReturnedType == targetType); if...
user2412672
1

votes
2

answer
367

Views

Rhino.Commons with StructureMap

Has anybody tried to use StructureMap for IoC with Rhino.Commons? Thanks
fromano
1

votes
1

answer
270

Views

Injecting non-primative types without wrapping them in an inteface in StructureMap

I have a simple SM Registry where I am configuring all my instances of IDynamicValue. I have some contructor arguments that are non-primative types (in my case a DateTime and a Predicate Of T). Is there a way I can inject these without having to wrap them in a class with an interface (so they can be...
Nic Strong
1

votes
1

answer
125

Views

How to use cumstomized configuration xml file?

I am going to use StructureMap as a way to do DI. I'll use xml as my DI configuration. I have two questions. The first one is how to use a customaized xml file name instead of StructureMap.Config? For example, in my console application, if I want to use myDIStructure.config file, what class and meth...
David.Chu.ca
1

votes
1

answer
369

Views

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...
David P
1

votes
2

answer
854

Views

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

In my DefaultRegistry I have this configuration: ForRequestedType().CacheBy(InstanceScope.HttpContext) .TheDefault.Is.OfConcreteType(); 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: PluginTypeConfiguration con...
abutnaru
1

votes
1

answer
1k

Views

How do I do this in Unity?

Jimmy Bogart has an article on using Automapper with an IoC container. He has an example using StructureMap but I am using Unity and I'm not sure how to use an InjectionConstructor properly. Below is the code from the Article and below that is my poor attempt. Can anyone tell me how to do this prop...
Robert Kozak
1

votes
1

answer
825

Views

StructureMap and passing null parameter to instance

I am creating an instance with StructureMap in code, and the constructor takes in a string. In the configuration I use a placeholder for the parameter. I am trying to create the object with the parameter value of null. When I get the object back from the ObjectFactory the value of the parameter i...
CSharpAtl
1

votes
3

answer
199

Views

Having trouble with Dependency Injection and ASP.NET MVC

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 requir...
Pure.Krome
1

votes
1

answer
1.8k

Views

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 o...
1

votes
1

answer
563

Views

StructureMap: CacheBy(InstanceScope.Singleton) question

I have a question about how InstanceScope.Singleton works, because I am getting some unexpected results here: I have a service that is dependent on Dao public MetaProjectService(IMetaProjectDao metaProjectDao) { _metaProjectDao = metaProjectDao; } and I have Dao that is dependent on ISession (Nhiber...
epitka
1

votes
3

answer
1.6k

Views

StructureMap Error 202 Setting up IOC container

I'm getting an error: StructureMap Exception Code: 202 No Default Instance defined for PluginFamily MVCPoco.Services.IService, MVCPoco.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Line 96: { Line 97: Type controllerType = base.GetControllerType(context, contro...
Diego
1

votes
1

answer
1.1k

Views

Scanning for types with AssembliesFromPath in StructureMap

I'm working on an application where we are using StructureMap 2.5.4 to scan a directory like below. ObjectFactory.Configure(scanner => scanner.Scan(x => { x.AssembliesFromPath(settings.Directory); x.AddAllTypesOf(typeof(IScannerConvention)).NameBy(n => n.Name); })); For some reason the types impleme...
Kristoffer Ahl
1

votes
2

answer
456

Views

Downloaded StructureMap but seems to be missing the Log4Net.Dll

I am currently following instructions in a book to develop an application. It asks me to download StructureMap and then move the StructureMap.Dll file and the Log4Net.dll into the bin files. The problem is there doesnt seem to be a Log4Net.dll file in the StructureMap files, the only other dll apart...
Rachel Shearer
1

votes
1

answer
336

Views

Rhino Commons Nhibernate Module w/ Structuremap

Has anyone gotten the NH session management bits from RhinoCommons to work with Structure Map? We already use SM and do not want a dependency on Windsor.
MarcR
1

votes
1

answer
110

Views

Is it possible to name a dependency with StructureMap?

I would like to be able to inject named dependencies into a class using StructureMap if that is at all possible. The main reason I want this right now is for connection string injection. I may be doing this the wrong way, but here's how I've got it (just need to add injection now): psuedo: public cl...
Max Schmeling
1

votes
3

answer
588

Views

IoC Container Hurdle for ASP.Net MVC Newb

I must admit that I'm new to ASP.Net MVC and I'm currently researching all the best practices on how to start my new project. So far I have understood the concepts of the Repository Pattern and Unit of Work and I have gone onto Dependency Injection and Inversion of Control (IoC). I have been looki...
nfplee
1

votes
1

answer
535

Views

Passing parameters on each wcf call

I am having this problem. I have integrated structuremap with wcf like it is described here: http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/07/29/integrating-structuremap-with-wcf.aspx the problem is that I am having classes which have constructor parameters like userId and applicationId...
Luka
1

votes
2

answer
136

Views

How do I use sturcturemap to pass two different implementations of a single interface into a constructor?

I have a constructor that take two interfaces, they are the same interface, but need to be different implementations: public class Foo { public Foo(IBar publicData, IBar privateData) { } } What I'd like to happen is that structuremap would pass in a concrete implementation of IBar as class PublicDat...
ilivewithian
1

votes
1

answer
232

Views

MVC 2.0 - different view based on URL with shared controls

I have 2 master pages. One is intended to be shown in a normal standalone website. The other is to be used in external sites as an Iframe. I want to be able to show the normal page at http://example.com/home/index and the iframed version at http://example.com/framed/home/index I want to have contr...
Josh
1

votes
1

answer
581

Views

StructureMap configure a profiled nested container

I've come across an unexpected outcome when trying to resolve an instance. It's probably better to explain in code. Here is the Registry used for ObjectFactory.Initialize: public MyRegistry : Registry { public MyRegistry() { this.For.Use(); this.For.Use().Named('Special'); this.Profile('Special', p...
awilinsk
1

votes
1

answer
215

Views

Injecting error logger with structuremap

I'm using Elmah for logging with a class that looks pretty much like this http://blog.omniaconnect.net/2009/07/30/using-a-static-class-for-logging-exceptions-using-elmah/ , should I inject this static class using structuremap?
Marcus
1

votes
2

answer
173

Views

StructureMap grouping of named instances

Long post - sorry.... I'm doing input validation for a WCF service and using StructureMap IoC to instantiate the appropriate validation objects. I have 2 different validation groups: Per object validation: means that one input parameter, will be resolve by the Ioc (e.g. Ioc.ResolveAll
jaspernygaard
1

votes
2

answer
1.1k

Views

StructureMap Registry DSL for static factory class

I'm trying to figure out if it's possible to represent the following using the StructureMap registry DSL... I want to have StructureMap inject a ILog into classes for me. I've seen examples of doing the following: For(typeof(ILog)).Use(typeof(Log)); However, I have a static factory class that creat...
goombaloon
1

votes
2

answer
1.4k

Views

Using IoC to provide a custom ModelMetadataProvider in MVC3

I'm currently overriding the default ModelMetadataProvider in the Global.asax file using this ModelMetadataProviders.Current = new RedSandMetadataProvider(ModelMetadataProviders.Current); and this works perfectly. But I'd like to use the IDependancyResolver feature of MVC3 to let IoC provide the Mod...
Nick Albrecht
1

votes
1

answer
602

Views

Problem with Setter injection with Structuremap

I am creating an instance of a type scoped to HTTPContextScoped. I am trying to figure out how to inject this specific instance into a property of the same type into an attribute that I don't have control over. I want to inject the specific instance of UnitOfWork into a property of IUnitOfWork ty...
pghtech
1

votes
1

answer
219

Views

MVC3 Architecture/Validation Question

I think this is a pretty simple task, but I can't for the life of me get it working. Environment - MVC3, FluentValidation, StructureMap. I have a ViewModel (RegisterViewModel) that has the following attributes { Email, IsBusiness, BusinessContact }. Email is required always, BusinessContact is requ...
firetoast
1

votes
1

answer
221

Views

StructureMap configuration help

I have an interface, called IRepository, with two implementations: SqlRepository SqlDualWriterRepository The first implementation is a regular SQL persistence implementation for objects of type T. It has a dependency on an instance of SqlConnectionStringProvider (which provides a connection string,...
Cristian Lupascu

View additional questions