Comments (10)
@pawelignaczak could you share your ABP version and format the code in the issue properly ?
from aspnetboilerplate.
Done
from aspnetboilerplate.
Thanks. Is it possible for you to prepare a sample project with this problem ?
from aspnetboilerplate.
That would be difficult as the current project is big. Basically We get an event from remote server that triggers an async request with a new UoW: _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew).
The a chain of async requests are called. My latest findigs is that the any async bolerplate repo calls like:
var interdto = await base.CreateAsync(input);
or
var list=_interactionsRepository.GetAllListAsync()
or
var dataReader = await command.ExecuteReaderAsync();
if i use say :
var dataReader = command.ExecuteReader();
Then it does not happen.
But i cannot avoid using:
var interdto = await base.CreateAsync(input);
from aspnetboilerplate.
In fact i randomly get below error when try to call :
var interdto = await base.CreateAsync(input);
System.InvalidOperationException: „A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.”
from aspnetboilerplate.
Could you share your startup.cs ? Especially services.AddAbp block.
from aspnetboilerplate.
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Castle.Facilities.Logging;
using Abp.AspNetCore;
using Abp.AspNetCore.Mvc.Antiforgery;
using Abp.Castle.Logging.Log4Net;
using AseeVT.Authentication.JwtBearer;
using AseeVT.Configuration;
using AseeVT.Identity;
using AseeVT.Web.Resources;
using Abp.AspNetCore.SignalR.Hubs;
using Abp.Dependency;
using Abp.Json;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json.Serialization;
using AseeVT.Hubs;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Identity;
using log4net;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Globalization;
using Microsoft.AspNetCore.Localization;
using AseeVT.Web.Models.AzureKeyVault;
using Azure.Identity;
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
using Microsoft.Data.SqlClient;
using System.Collections.Generic;
namespace AseeVT.Web.Startup
{
public class Startup
{
private readonly IWebHostEnvironment _hostingEnvironment;
private readonly IConfigurationRoot _appConfiguration;
public Startup(IWebHostEnvironment env)
{
_hostingEnvironment = env;
_appConfiguration = env.GetAppConfiguration();
}
public void ConfigureServices(IServiceCollection services)
{
var azureKeyVaultConfig = _appConfiguration.GetSection("AzureKeyVault").Get<AzureKeyVaultConfig>();
var clientSecretCredential = new ClientSecretCredential(
azureKeyVaultConfig.TenantId,
azureKeyVaultConfig.ClientId,
azureKeyVaultConfig.ClientSecret );
SqlColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = new SqlColumnEncryptionAzureKeyVaultProvider(clientSecretCredential);
SqlConnection.RegisterColumnEncryptionKeyStoreProviders(
customProviders: new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>(comparer: StringComparer.OrdinalIgnoreCase)
{
{ SqlColumnEncryptionAzureKeyVaultProvider.ProviderName, azureKeyVaultProvider }
});
// MVC
services.AddControllersWithViews(
options =>
{
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
}
)
.AddRazorRuntimeCompilation()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver = new AbpMvcContractResolver(IocManager.Instance)
{
NamingStrategy = new CamelCaseNamingStrategy()
};
});
//services.ConfigureApplicationCookie(o =>
//{
// o.ExpireTimeSpan = TimeSpan.FromHours(8);
// o.SlidingExpiration = false;
//});
services.AddSingleton<IPostConfigureOptions<SecurityStampValidatorOptions>, ConfigureSecurityStampValidatorOptionsService>();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(240);
options.SlidingExpiration = false;
options.AccessDeniedPath = "/Forbidden/";
});
IdentityRegistrar.Register(services);
AuthConfigurer.Configure(services, _appConfiguration);
services.AddScoped<IWebResourceManager, WebResourceManager>();
var options = new JsonSerializerOptions
{
ReferenceHandler = ReferenceHandler.Preserve
};
services.AddSignalR(o =>
{
o.EnableDetailedErrors = true;
}).AddJsonProtocol(options =>
{
options.PayloadSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve;
});
// Configure Abp and Dependency Injection
services.AddAbpWithoutCreatingServiceProvider<AseeVTWebMvcModule>(
// Configure Log4Net logging
options => options.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig(
_hostingEnvironment.IsDevelopment()
? "log4net.config"
: "log4net.Production.config"
)
)
);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
//app.UsePathBase(new PathString("/app"));
app.UseAbp(); // Initializes ABP framework.
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
//app.UseExceptionHandler("/Error");
}
else
{
app.UseExceptionHandler("/Error");
}
app.Use(async (context, next) =>
{
LogicalThreadContext.Properties["CorrelationId"] = context.TraceIdentifier;
await next.Invoke();
});
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
app.UseAuthorization();
//app.UseSession();
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<AbpCommonHub>("/signalr");
endpoints.MapHub<AcdHub>("/signalr-acd");
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
});
}
}
}
from aspnetboilerplate.
Thanks. This seems fine. Is it possible that your code has any async over sync usages ? If you are using Jetbrains Rider, you can find such usages in your code. If not, you can try to remove TransactionScopeOption.RequiresNew
if there is no special reason to use it.
from aspnetboilerplate.
Well that's the point. We receive TCP events from other system and create an asyn event from it that process some actions on services. At the same time the services can be accessed from say frontend or SignalR.
from aspnetboilerplate.
I mean only the code in your app, not how it is called outside from your app.
from aspnetboilerplate.
Related Issues (20)
- Performance issue with many tenant based features and opportunity to improve it. HOT 2
- Another main project HOT 1
- [Question] Test for login functionality HOT 1
- ASP.NET boilerplate new module's dbcontext recreate abp main tables HOT 6
- css/js stop working after deployed on production asnetboilerplate as out of process HOT 7
- LoginAsync() saves "Success" in ABPLoginAttempts table before verifying 2FA code
- OnlineClientManager and Redis usage problem
- Can't check database value in Abp.FluentValidation in aspnet boilerplate HOT 4
- Error IOnlineClientManager was not registered upgrade from 9.1.2 to 9.1.3 HOT 1
- EfCoreAsyncQueryableExecuter asynchronous cancel mode should be implemented
- Detected Package Downgrade System.Net.Premitives from 4.3.0 to 4.0.11. HOT 1
- GetAllAsync is missing from the IRepository interface HOT 4
- GetAllIncludingAsync is missing from the IRepository interface.
- Low efficiency of soft deletion HOT 3
- Clock.Provider not working in abp v9 HOT 7
- GetAll Readonly method to IRepository HOT 1
- There is no async implementation of the AbpHangfireAuthorizationFilter.
- Retrieval of permissions is only possible synchronously. HOT 1
- When changing the language to Arabic, the layout didn't change to RTL and is still as en lang. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnetboilerplate.