Base solution for your next web application
Open Closed

Issue with integration of DevExpress Grid control using ASP.NET Zero framework 10.3.0 #10419


User avatar
0
vsolve created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? 10.3.0
  • What is your product type (Angular or MVC)? JQuery
  • What is product framework type (.net framework or .net core)? .NET Core MVC

If issue related with ABP Framework

  • What is ABP Framework version? 6.3.1

If issue is about UI

Now we are facing issue with DevExpress grid controls with ASP.NET Zero. We created API and it is fetching the data as json. We could not pass the data to the DevExpress Grid control. The same functionality is working well with DevExpress and .NET without ASP.NET Zero.

ASP.NET Zero is giving problem to us. I am sharing the error below. We need right solution for this to use ASP.Net Zero wiht DevExpress Grid controls and other controls.

System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'TSolveDbContext'. at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed() at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider() at Microsoft.EntityFrameworkCore.DbContext.get_ChangeTracker() at Microsoft.EntityFrameworkCore.Query.CompiledQueryCacheKeyGenerator.GenerateCacheKeyCore(Expression query, Boolean async) at Microsoft.EntityFrameworkCore.Query.RelationalCompiledQueryCacheKeyGenerator.GenerateCacheKeyCore(Expression query, Boolean async) at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerCompiledQueryCacheKeyGenerator.GenerateCacheKey(Expression query, Boolean async) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.System.Collections.IEnumerable.GetEnumerator() at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value) at Microsoft.AspNetCore.Mvc.NewtonsoftJson.NewtonsoftJsonResultExecutor.ExecuteAsync(ActionContext context, JsonResult result) at Microsoft.AspNetCore.Mvc.NewtonsoftJson.NewtonsoftJsonResultExecutor.ExecuteAsync(ActionContext context, JsonResult result) at Microsoft.AspNetCore.Mvc.NewtonsoftJson.NewtonsoftJsonResultExecutor.ExecuteAsync(ActionContext context, JsonResult result) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi **@vsolve **

    Could you also share your Controller or AppService code which throws this exception ?

  • User Avatar
    0
    vsolve created

    /Action Method [HttpGet] public JsonResult List(DataSourceLoadOptions options) { var data = _countryAppService.GetPage(options); return Json(data); }

    //Service Layer public LoadResult GetPage(DataSourceLoadOptionsBase options) { var query = _countryRepository.GetAll() .Select(s => new CountryListDto { Id = s.Id, Name = s.Name, }); return DataSourceLoader.Load(query, options); } }

    //Cshtml @(Html.DevExtreme().DataGrid<TSolve.Countries.Dto.CountryListDto>() .ID("CountryList") .ShowBorders(true) .AllowColumnReordering(true) .DataSource(d => d.Mvc() .Controller("Country") .LoadAction("List") .UpdateAction("Put") .Key("id") .DeleteAction("Delete")) .Editing(editing => { editing.Mode(GridEditMode.Batch); editing.AllowDeleting(true); editing.AllowUpdating(true); editing.UseIcons(true); }) .Columns(columns => { columns.AddFor(m => m.Name);

                            columns.Add().Type(GridCommandColumnType.Buttons)
                            .Buttons(b =>
                            {
                                b.Add().Icon("edit").OnClick("function(e) { countryAddEdit.showModel(e, countryList.refreshList); }");
                                b.Add().Name(GridColumnButtonName.Delete);
                            });
                        })
                            .Paging(p => p.PageSize(10))
                            .FilterRow(f => f.Visible(true))
                            .HeaderFilter(f => f.Visible(true))
                            .RemoteOperations(true)
                            )
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @vsolve

    I think your controller is not an AbpController (doesn't inherit from YourProjectNameControllerBase). You can try adding [UnitOfWork] attribute to GetPage action and see if it works.

  • User Avatar
    0
    vsolve created

    We are using ABP controller. We tried with UnitOfWork also. Still facing issues.

    At the same time, excel data import process also having issues.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    We have provided support via email.