Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6871567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:49:19+00:00 2026-05-27T03:49:19+00:00

I’m trying to put together a real simple MVC DataBind sample. I’m comparing Telerik

  • 0

I’m trying to put together a real simple MVC DataBind sample. I’m comparing Telerik vs DevExpress Grid in MVC3. One of the goals was to use Enitiy Framework and Autofac in a DDD approach, this making it as close to how our projects are currently and will be when using the new controls. Creating the fairest test.

Telerik was a breeze and I have to imagine that DevExpress is just as easy to use but I keep running into an exception which I can’t get solved.

{“This resolve operation has already ended. When registering
components using lambdas, the IComponentContext ‘c’ parameter to the
lambda cannot be stored. Instead, either resolve IComponentContext
again from ‘c’, or resolve a Func<> based factory to create subsequent
components from.”}

I did some research on it and I was already calling the c.Resolve() which many said was the fix, so I’m not sure why I keep getting this problem, Telerik had no trouble with the same exact setup.

I’m pretty sure its not a DevExpress issue and something I’m doing wrong with autofac I think. However if this is how DevExpress and autofac work together this will be a problem since we heavily rely on autofac and I really would hate to do something hokey to get it to work when Telerik works so easily out of the box.

Can someone please tell me if I am doing something wrong and point me in the right direction, or tell me if this is a DevExpress and autofac issue and not something that can be fixed easily and requires a workaround?

VIEW

@using System.Web.UI.WebControls
@model IEnumerable<Domain.Entities.FactResellerSale>
@{
    ViewBag.Title = "GridView";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>GridView</h2>

@Html.DevExpress().GridView(
        settings =>
            {
                settings.Name = "gvData";
                settings.Width = Unit.Percentage(100);

                settings.SettingsText.Title = "Fact Resllers Sale";
                settings.Settings.ShowTitlePanel = true;
                settings.Settings.ShowStatusBar = GridViewStatusBarMode.Visible;
                settings.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;
                settings.SettingsPager.AllButton.Text = "All";
                settings.SettingsPager.PageSize = 10;
            }
        ).Bind(Model).GetHtml()

Controller

using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Domain.Entities;
using Domain.Repository;

namespace DevExpressMvcRazor.Controllers
{
    public class GridViewController : Controller
    {
        private readonly IAdventureRepository _repository;

        public GridViewController(IAdventureRepository repository)
        {
            _repository = repository;
        }

        //
        // GET: /GridView/

        public ActionResult GridView()
        {
            return View("GridView", GetFactResllerSales());
        }

        private IList<FactResellerSale> GetFactResllerSales()
        {
            return _repository.GetFactResllerSales().Take(10).ToList();
        }
    }
}

Global.asax

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Autofac;
using Autofac.Integration.Mvc;

namespace DevExpressMvcRazor
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            var builder = new ContainerBuilder();
            builder.RegisterModule<DevExpressModule>();
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
    }
}

DevExpressModule

using Autofac;
using Autofac.Integration.Mvc;
using Domain;
using Infrastructure;

namespace DevExpressMvcRazor
{
    public class DevExpressModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            builder.RegisterModule<InfrastructureModule>();
            builder.RegisterModule<DomainModule>();
            builder.RegisterModule<AutofacWebTypesModule>();
        }
    }
}

InfrastructureModule

    public class InfrastructureModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder.Register(c => new PropertyInjectedLazyLoadedObjectContextFactory(c.IsRegistered, c.Resolve))
                .As<IObjectContextFactory>()
                .InstancePerLifetimeScope();

            builder.Register(c => new UnitOfWork(c.Resolve<IObjectContextFactory>()))
                .As<ISession>()
                .As<IObjectContextProvider>()
                .InstancePerLifetimeScope();


            //Repositories
            builder.Register(c => new AdventureRepository(c.Resolve<IObjectContextProvider>()))
                .As<IAdventureRepository>()
                .InstancePerLifetimeScope();
        }
    }

Repository

public class AdventureRepository : IAdventureRepository
{
    private readonly IObjectContextProvider _contextProvider ;

    public AdventureRepository(IObjectContextProvider contextProvider)
    {
        _contextProvider = contextProvider;
    }

    public IQueryable<FactResellerSale> GetFactResllerSales()
    {
        return _contextProvider.GetContext<TelerikVsDevExpressModelContext>().GetIQueryable<FactResellerSale>();
    }
}

Everything else is the same for Telerik so I will just post the View which the Telerik one works no problem.
Telerik View

@model IEnumerable<Domain.Entities.FactResellerSale>              
@{
    ViewBag.Title = "GridView";
}

<h2>GridView</h2>


@(Html.Telerik().Grid(Model)
    .Name("Grid")
    .PrefixUrlParameters(false)
    .Columns(columns =>
    {
        columns.Bound(o => o.ProductKey).Width(50);
        columns.Bound(o => o.DimDate.FullDateAlternateKey);
        columns.Bound(o => o.DimReseller.ResellerName);
        columns.Bound(o => o.DimEmployee.FullName);
        columns.Bound(o => o.SalesOrderNumber);
    })
    .Groupable()
    .Pageable()
    .Sortable()
    .Filterable()
)

I’m using:

  • MVC 3
  • Autofac 2.5.2.830
  • DevExpress 11.1.8.0
  • Telerik 2011.3.1115.340
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:49:19+00:00Added an answer on May 27, 2026 at 3:49 am

    Your problem is here:

    
     builder.Register(c => new PropertyInjectedLazyLoadedObjectContextFactory(c.IsRegistered, c.Resolve))
                    .As<IObjectContextFactory>()
                    .InstancePerLifetimeScope();
    

    In order to inject a handle to c (IComponentContext) you must resolve it first. Change your code like so:

    
     builder.Register(c => {
        var context = c.Resolve<IComponentContext>();
        return new PropertyInjectedLazyLoadedObjectContextFactory(context.IsRegistered, context.Resolve))
        }
      .As<IObjectContextFactory>()
      .InstancePerLifetimeScope();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.