Call UserRegistrationManager.RegisterAsync() throw exception in a domain event
See original GitHub issueCall UserRegistrationManager.RegisterAsync() throw exception in a domain event
public class EventCreateUser : MainxxDomainServiceBase, IEventHandler<Records.Events.AddUserRecordEventData>, ITransientDependency
{
private readonly UserRegistrationManager _userRegistrationManager;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public EventCreateUser(
IUnitOfWorkManager unitOfWorkManager,
UserRegistrationManager userRegistrationManager)
{
_userRegistrationManager = userRegistrationManager;
_unitOfWorkManager = unitOfWorkManager;
}
public async void HandleEvent(AddUserRecordEventData eventData)
{
var user = await _userRegistrationManager.RegisterAsync(
eventData.AddUserRecordData.UserName,
eventData.AddUserRecordData.UserName,
eventData.AddUserRecordData.UserName + "@test.core",
eventData.AddUserRecordData.UserName,
eventData.AddUserRecordData.Password,
true, null);
}
}
Error Massage
System.ObjectDisposedException
HResult=0x80131622
Message=Cannot access a disposed object. A common cause of this error is disposing a context 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, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.Cannot access a disposed object. A common cause of this error is disposing a context 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, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_Model()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
at Mainxx.Authorization.Users.UserRegistrationManager.<RegisterAsync>d__13.MoveNext() in S:\Gitee\Mainxx\aspnet-core\src\Mainxx.Core\Authorization\Users\UserRegistrationManager.cs:line 82
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
- Abp 3.7.2
- .Net Core2.1 .
Your answers are very important to me, thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
CQRS - Domain Exceptions Vs Events for ...
I'm wondering if it's preferable to publish events rather than throw exceptions from aggregates. Say, I have a domain where there is a ......
Read more >Exception throwed when calling RegisterAsync of ...
I have a below method , written using `C#` public async Task<DeviceRegistrationResult> RegisterDevice(ProvisioningDeviceClient provClient) ...
Read more >ABP在领域事件中异步调用方法抛异常转载
RegisterAsync抛异常Call UserRegistrationManager.RegisterAsync() throw exception in a ... RegisterAsync() throw exception in a domain event.
Read more >Validation Error as an event returned by the Domain Layer
I assume the validation error indicates the domain service is prevented from completing the requested task. In that case an event is not ......
Read more >Domain events: simple and reliable solution
The idea is simple: if you want to indicate an event that is significant to your domain, raise this event explicitly and let...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
[UnitOfWork]
attribute.virtual
.IAsyncEventHandler
if async.Because I need to write a callback interface and the other party requires a result to be returned within 2 seconds, I didn’t wait on my end and calling the asynchronous method of efcore would result in an error. The error is as follows:
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: 'SqlServerDbContext'.
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. ObjectDisposed_ObjectName_Name
controllerpublic async Task<IActionResult> ReceiveCard() { _jdyCardService.ReceiveData(_Body); return Ok("success"); }