Nargzul
asked on
Problem using scope with linq
I must specify the isolation level for some transaction, so I've tried something like in the code snippet.
But we always have an exception.
I'm sorry, I've VS in french and all exception message are in french too :(
Information about the exception:
à System.Data.EntityClient.E ntityConne ction.Open StoreConne ctionIf(Bo olean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFail ure)
à System.Data.EntityClient.E ntityConne ction.Open ()
à System.Data.Objects.Object Context.En sureConnec tion()
à System.Data.Objects.Object Query`1.Ge tResults(N ullable`1 forMergeOption)
à System.Data.Objects.Object Query`1.Sy stem.Colle ctions.Gen eric.IEnum erable<T>. GetEnumera tor()
à System.Linq.Enumerable.Fir st[TSource ](IEnumera ble`1 source)
à System.Data.Objects.ELinq. ObjectQuer yProvider. <GetElemen tFunction> b__0[TResu lt](IEnume rable`1 sequence)
à System.Data.Objects.ELinq. ObjectQuer yProvider. ExecuteSin gle[TResul t](IEnumer able`1 query, Expression queryRoot)
à System.Data.Objects.ELinq. ObjectQuer yProvider. System.Lin q.IQueryPr ovider.Exe cute[S](Ex pression expression)
à System.Linq.Queryable.Firs t[TSource] (IQueryabl e`1 source)
à pages_Default.makeLoan(ges tstockEnti ties gse) dans d:\WorkSpaces\geststock\Ge stStock2\p ages\makeL oan.aspx.c s:ligne 168
à QueryHelper.insertDB(Inser tDbDelegat e methodThatWriteDB, IsolationLevel isoLevel, Page senderPage) dans xxxxx\QueryHelper.cs:ligne 47
ex = {"Échec du fournisseur sous-jacent sur Open."}
//If I translate this, it would be something like : "Failure of the underlying provider on Open."
InnerException = {"L'accès réseau de MSDTC (Distributed Transaction Manager) a été désactivé. Activez DTC pour l'accès réseau dans la configuration de sécurité de MSDTC à l'aide de l'outil administratif des services de composants."}
//Translation
Access network MSDTC (Distributed Transaction Manager) has been disabled. Activate DTC for network access in the security configuration for MSDTC using the Services administrative tool components.
I've a MS SQL 2005 standard Database and I currently only use the "debug" and "local" server of visual studio.
So what can I make?
Is there a better way to manage isolation level for a transaction?
But we always have an exception.
I'm sorry, I've VS in french and all exception message are in french too :(
Information about the exception:
à System.Data.EntityClient.E
à System.Data.EntityClient.E
à System.Data.Objects.Object
à System.Data.Objects.Object
à System.Data.Objects.Object
à System.Linq.Enumerable.Fir
à System.Data.Objects.ELinq.
à System.Data.Objects.ELinq.
à System.Data.Objects.ELinq.
à System.Linq.Queryable.Firs
à pages_Default.makeLoan(ges
à QueryHelper.insertDB(Inser
ex = {"Échec du fournisseur sous-jacent sur Open."}
//If I translate this, it would be something like : "Failure of the underlying provider on Open."
InnerException = {"L'accès réseau de MSDTC (Distributed Transaction Manager) a été désactivé. Activez DTC pour l'accès réseau dans la configuration de sécurité de MSDTC à l'aide de l'outil administratif des services de composants."}
//Translation
Access network MSDTC (Distributed Transaction Manager) has been disabled. Activate DTC for network access in the security configuration for MSDTC using the Services administrative tool components.
I've a MS SQL 2005 standard Database and I currently only use the "debug" and "local" server of visual studio.
So what can I make?
Is there a better way to manage isolation level for a transaction?
try
{
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = isoLevel}))
{
using (geststockEntities gse = new geststockEntities(cs_admin))
{
methodThatWriteDB(gse);
objectsAdded = gse.SaveChanges();
if (objectsAdded == 0) throw new Exception();
scope.Complete();
addUserMessage(senderPage, "Insertion OK");
}
}
}
catch (Exception ex)
{
addErrorMessage(senderPage, "Error message");
}
Is the database service running on a different server? If so, have you enabled MS DTC on that server?
ASKER
Yes he is running on a different server, and we've activated this server, but I don't know if I've done all these manipulation correctly
You shall try configuring your DTC as per the attached screenshot
DTC.GIF
DTC.GIF
ASKER
We've already the same thing :(
on both the machines?
ASKER
both? Which other than the sql server?
We just have a visual studio to test currently
We just have a visual studio to test currently
Are you trying to open more than one database connection? If so, try closing the 1st connection before opening a new connection?
ASKER
No, we just have one database.(and our developper are under vista(sigh))
you didn't understand my point - I asked whether you are opening more than one database connection in your application/program...phew
ASKER
I've added explicit "dispose()" to the object context, but nothing change.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.