1
1

Hello everyone,

I am currently doing a C# Windows Forms project with Data Objects .NET 4.4. I create a domain and a session (which has the ClientProfile option turned on) that I keep as global variables in the whole form. Of course, I use the session.SaveChanges() method after each change on the database. When I click on a button of my form, a lot of tasks are performed and the application works well; however, after a couple of clicks, I get an unhandled Aggregate exception, and I don't really know its origin. I think it is unlikely to be a memory leak.

Here is the detailed exception :

Xtensive.Core.AggregateException was unhandled

Message=A set of exceptions is caught.

  • Source=Xtensive.Core

StackTrace:

at Xtensive.Core.ExceptionAggregator.Dispose()

at Xtensive.Disposing.DisposableSet.System.IDisposable.Dispose()

at Xtensive.IoC.ServiceContainer.Dispose(Boolean disposing)

at Xtensive.IoC.ServiceContainerBase.Finalize()

InnerException: Xtensive.Orm.StorageException

Message=Error 'Unknown'. Original message: Internal .Net Framework Data Provider error 1.

  • Source=Xtensive.Orm

StackTrace:

at Xtensive.Storage.Providers.Sql.Driver.CloseConnection(Session session, SqlConnection connection)

at Xtensive.Storage.Providers.Sql.SessionHandler.Dispose()

at Xtensive.Orm.Internals.ChainingSessionHandler.Dispose()

at Xtensive.Core.DisposableExtensions.DisposeSafely(IDisposable disposable)

at Xtensive.Orm.Session.Dispose()

at Xtensive.Disposing.DisposableSet.<system.idisposable.dispose>b__0(IDisposable d)

at Xtensive.Core.ExceptionAggregator.ExecuteT

InnerException: System.InvalidOperationException

Message=Internal .Net Framework Data Provider error 1.

  • Source=System.Data

StackTrace:

at System.Data.ProviderBase.DbConnectionInternal.PrePush(Object expectedOwner)

at System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal obj, Object owningObject)

at System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)

at System.Data.SqlClient.SqlInternalConnection.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)

at System.Data.SqlClient.SqlConnection.Close()

at Xtensive.Sql.SqlConnection.Close()

at Xtensive.Storage.Providers.Sql.Driver.CloseConnection(Session session, SqlConnection connection)

I would be glad if someone could help me. Best regards

asked Aug 25 '11 at 10:13

Jonathan's gravatar image

Jonathan
15114

edited Aug 25 '11 at 10:34


2 Answers:

Hi,

I finally found the answer to this problem, it was because I had forgotten to take out the domain.OpenSession() from my ProgramForDO.GetMetersFromTable() method. Actually, the domain.OpenSession() should be called only once and I had called it twice.

However, I have a new problem in the following method:

public void DeleteDemandInDb(List<CustomerPerimeter> demandedMeters, string pdl){
  demandedMeters
  .Where(meter => meter.Pdl == pdl)
  .Remove();}

Exception :

System.InvalidOperationException occurred

Message=Active Session is required for this operation. Use Session.Open(...) to open it.

Source=Xtensive.Orm

StackTrace:

   at Xtensive.Orm.Session.Demand()
   at Xtensive.Orm.QueryableExtensions.Remove[T](IEnumerable`1 entities)
   at CustomerOrdersInDatabase.Services.DatabaseFiller.DeleteDemandInDb(List`1 demandedMeters, String pdl)

It seems like the Remove() method requires an active session ; however, since I am on client profile, that should not be a problem...

Thank you again

answered Aug 26 '11 at 05:45

Jonathan's gravatar image

Jonathan
15114

edited Aug 26 '11 at 05:52

Jonathan, try using Session.Remove() method instead. This implies you have to pass a reference to a session or use

using (session.Activate()) {

  // do some stuff 
  // Session.Current is available within this region
}
(Aug 26 '11 at 05:57) Dmitri Maximov Dmitri%20Maximov's gravatar image

Thank you, it worked perfectly!

(Aug 26 '11 at 06:03) Jonathan Jonathan's gravatar image

You are welcome =)

(Aug 26 '11 at 06:09) Dmitri Maximov Dmitri%20Maximov's gravatar image

Any sample solution, or at least model with query you made will help a lot.

answered Aug 25 '11 at 10:48

Peter%20%C5%A0ulek's gravatar image

Peter Šulek
492313236

Hi Peter,

Thank you for your answer. I uploaded the useful D.O. files of my project so that you can have a look at them : the database filler is not my problem though. I hope you will be able to undersatand my program. The button where the exception arises is the Go Button.

Here you are : Project files

If needed, I can provide the entire solution. Thanks again

(Aug 25 '11 at 11:17) Jonathan Jonathan's gravatar image

likely i will try to reproduce your case, be in touch.

(Aug 26 '11 at 03:14) Peter Šulek Peter%20%C5%A0ulek's gravatar image

I could not build/reproduce your issue. Could you post full exception stacktrace here?

(Aug 26 '11 at 03:35) Peter Šulek Peter%20%C5%A0ulek's gravatar image

Peter,

The stack Trace I gave you earlier is the most detailed version of the exception ( Copied the detail on clipboard ). If I give you the stack trace only, you get this : at Xtensive.Core.ExceptionAggregator.Dispose() at Xtensive.Disposing.DisposableSet.System.IDisposable.Dispose() at Xtensive.IoC.ServiceContainer.Dispose(Boolean disposing) at Xtensive.IoC.ServiceContainerBase.Finalize() InnerException: Error 'Unknown'. Original message: Internal .Net Framework Data Provider error 1.

Here is a screenshot : Exception

Thank you

(Aug 26 '11 at 04:27) Jonathan Jonathan's gravatar image

In screenshot i see there are some inner exceptions, could you expand it and put here all inner exceptions?

(Aug 26 '11 at 04:32) Peter Šulek Peter%20%C5%A0ulek's gravatar image

The inner exceptions are actually already in my 1st post : there are 3 of them.

EDIT : Here is the complete detail, hope it helps you find a solution Detailed Exception

(Aug 26 '11 at 04:42) Jonathan Jonathan's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA