Closed WindingWinter closed 4 months ago
When you dispose the container, it calls dispose on any disposable objects you've resolved.
If you can comment out your code's Dispose method and the issue stops, that's a pretty clear indication that the problem is in your code's method. You'll need to debug that yourself; debugging your code for you isn't a service we can offer.
This is going to be very vague, so I would appreciate if you can bear with me and give me some pointers or understanding, however vague they could be.
Here's the situation, my nunit console agent crashed with either
STATUS_STACK_BUFFER_OVERRUN
orheap corruption error
, and given that the test list takes a long time to run, I can't easily reproduce the problem in a small sample.But one thing I do notice is that, if I disable the Autofac
container.dispose
in just one of the test ( the one that immediately precedes the point where the Nunit console agent crashes), then the nunit console agent will not crash, and can finish running.If I just run the offending test on its own, then there is no crash at all.
This is the typical structure of my test:
Alternatively, I can also stop the crash by only commenting out the content of a
Dispose
method of a class ( eg:Undo
) that is resolved from Autofac.In the
Undo.Dispose
, that's all that I have got, no idea why commenting them will stop the crash:And here's another interesting finding:
I don't know why if
undo.Dispose
is called bycontainer.Dispose
, then it will crash the nunit agent ( that's my assumption, could be invalid). Is there anything that Autofac dispose handles the dispose differently than how we normally handle it?