The Description I had a legacy type that is HttpRequestScoped and a legacy web service consuming that service. To resolve services in legacy concerns, I have a global resolver. This was all working well in 1.4, and now that I'm using 2.1.12 I'm experiencing DependencyResolutionException.
The Code In 2.1.12, my Global.asax.cs:
builder.R...
I am using Autofac 2.1.12 to handle my dependency injection, and am having trouble with one specific issue. I can't seem to resolve a NameValueCollection dependency.
Consider the following code snippet:
class Foo
{
public Foo(NameValueCollection collection) { }
}
static class Run
{
public static void Main()
{
var b...
I see from poking around in the 1.4.4 source that Autofac's ASP.NET integration (via Autofac.Integration.Web) peforms injection of properties on the Page as part of the HttpContext.PreRequestHandlerExecute event handling, but that the page's child controls don't get their properties injected until Page.PreLoad.
What this means, though i...
I've created a Wcf Service to back a Ajax page (.Net 3.5). It's hosted in IIS 6.1 Integrated Pipeline. (The rest of Autofac is setup correctly for Web Forms integration).
Everything works fine and dandy with the normal Wcf pipeline. However when I plug in the Autofac Wcf Integration (as per the Autofac wiki) I get this delightful exc...
I'm creating an ASP.NET MVC 2 (RTM) project that uses areas. The Index action of the Home controller of one area needs to use RenderAction to generate a sub-section of the page. The action called is also defined in the same Home controller. So the call should just be:
<% Html.RenderAction("List") %>
However, I get an exception:
A pub...
I'm using Autofac. I want to inject a different implementation of a dependency based on an attribute I apply to the constructor parameter. For example:
class CustomerRepository
{
public CustomerRepository([CustomerDB] IObjectContainer db) { ... }
}
class FooRepository
{
public FooRepository([FooDB] IObjectContainer db) { ... }
...
Hi all,
Has stated on the title, I'm trying to get autofac to resolve a type, that, as seen on the image bellow, seems registered.
Any thoughts on why the exception? Thanks
UPDATE 1
Hi, I've moved to the latest build of the autofac.
I'm registering the DemoService this way:
public class DependenciesModule : Autofac.Module
{
prot...
I'm hitting paralysis by analysis I think...
Which should I go for for my first IOC container: Autofac or Ninject?
(Just want an open source, nice and simple, IOC container)
...
I want/need to compile autofac with asp.net mvc 2 website. I want to step thru the source to see how it works. But here is my problem. The binaries for mvc dll is apparently bound for asp.net mvc 1. I am having trouble working out what the settings for the project file need to be for .Net 3.5 and asp.net mvc 2. one is the NET35 directiv...
I'm planning to use Autofac IoC for my project where I must implement auditing (Who, What is doing in application). I was already read a lot of articles on this subject (auditing).
My intention was to use method interception to implement this functionality.
I know that Unity support this, but I was wondering if I can use Autofac for thi...
I've got an application where a shared object needs a reference to a per-request object.
Shared: Engine
|
Per Req: IExtensions()
|
Request
If i try to inject the IExtensions directly into the constructor of Engine, even as Lazy(Of IExtension), I get a "No scope matching [Request] is ...
I'm currently doing a bit of experimenting using Autofac-1.4.5.676, autofac contrib and castle DynamicProxy2. The goal is to create a coarse-grained profiler that can intercept calls to specific methods of a particular interface.
The problem: I have everything working perfectly apart from the selective part. I could be wrong, but I ...
I'm trying to resolve the AccountController in my application, but it seems that I have a lifetime scoping issue.
builder.Register(c => new MyDataContext(connectionString)).As<IDatabase>().HttpRequestScoped();
builder.Register(c => new UnitOfWork(c.Resolve<IDatabase>())).As<IUnitOfWork>().HttpRequestScoped();
builder.Register(c => new...
If a program has literally just deserialized an object (doesn't really matter how, but just say BinaryFormatter was used).
What is a good design to use for re-injecting the dependencies of this object?
Is there a common pattern for this?
I suppose I would need to wrap the Deserialize() method up to act as a factory inside the containe...
I am compiling: PropertyInject wiki page
why this line:
builder.RegisterType().InjectProperties();
doesn't compile? how to do property inject in autofac?
I am using vs2010, autofac 2.1.13.813.
thanks.
EDIT:
after investigation, PropertyInjection should be like this in new version of AutoFac:
builder.RegisterType().PropertiesAutow...
I have two areas:
ControlPanel and Patients.
Both have a controller called ProblemsController that are similar in name only. The desired results would be routes that yield /controlpanel/problems => MyApp.Areas.ControlPanel.Controllers.ProblemsController and /patients/problems => MyApp.Areas.Patients.Controllers.ProblemsController.
Ea...
I'm running into an issue with Autofac2 and MVC2. The problem is that I am trying to resolve a series of dependencies where the root dependency is HttpRequestScoped. When I try to resolve my UnitOfWork (which is Disposable), Autofac fails because the internal disposer is trying to add the UnitOfWork object to an internal disposal list ...
I'm trying to figure out how to resolve a instance somewhere in the code.
At the application startup I registered a type
static void Main()
{
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>();
}
Now, how can I resolve an instance somewhere in the code ?
In structure mam there is a static object...
I'm building an application which uses AutoFac 2 for DI. I've been reading that using a static IoCHelper (Service Locator) should be avoided.
IoCHelper.cs
public static class IoCHelper
{
private static AutofacDependencyResolver _resolver;
public static void InitializeWith(AutofacDependencyResolver resolver)
{
_res...
I am currently attempting to remove a number of .Resolve(s) in our code. I was moving along fine until I ran into a named registration and I have not been able to get Autofac resolve using the name. What am I missing to get the named registration injected into the constructor.
Registration
builder.RegisterType<CentralDataSessionFacto...