WCF+MSMQ and DAAB problem.

S

Stefano C.

Hi,
Can anyone help me with saing why tha attached code return an error if used
from a WCF service with MSMQ binding?
Error returned is on db2.ExecuteReader (...
and is : "There is already an open DataReader associated with this Command
which must be closed first."
private void ErrorTestFunc()
{
Database db1 =
DatabaseFactory.CreateDatabase("DefaultConnection");
System.Data.IDataReader Dr1 =
db1.ExecuteReader(System.Data.CommandType.Text, "select * from ASPNET_USERS
");
while (Dr1.Read())
{
Database db2 =
DatabaseFactory.CreateDatabase("DefaultConnection");
System.Data.IDataReader Dr2 =
db2.ExecuteReader(System.Data.CommandType.Text, "select * from ASPNET_USERS
");
Dr2.Close();
Dr2.Dispose();
}
Dr1.Close();
Dr1.Dispose();
}

thankyou
 
S

sloan

You need a try/finally block to make sure things clean up properly.


I have a "cleaner" sample of wcf with msmq here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!158.entry

IZebraCollection SerializeZebras shows the try/finally block that is cleaner
than what you have.


throw new ArgumentNullException(string.Format ("The ZebraUUID cannot be
null/empty...{0}" , izeb.ZebraName ));

I also show how to code up an error handler (for msmq) on the server(host).

.................
 
S

sloan

Get the code, run the program, and hit "button3" and "button4".

You'll see the error handler for msmq work.
 
S

Stefano C.

Thankyou verymuch for the moment.
I'm going to make some test with your informations.
 
S

Stefano C.

I have replied without reading with attention your messages.
Those seems out of the topic of my questions.
The problem is not in the error handling. I have already implemented poison
messaging.
The problem is that same identical code executed from different hosting
class if i run those code from WinForm app,asp app,wcf service there are no
exception. I recevie an exception only when i run this function form a WCF
that with MSMQ bindings. Only in this case. Same identical service without
msmq binding do not thorow axception. There are no additional code only the
test function that use DAAB.
I have uploaded a test example on codeplex (without exception
implementetation becuse this not the problem
http://entlib.codeplex.com/Project/...entlib&WorkItemId=24178&FileAttachmentId=8889
 
S

sloan

You have a nested datareader? (I didn't see that at first, now I see it)

I would chase the specific exception:
http://www.google.com/search?source...d+which+must+be+closed+first"&aq=f&oq=&aqi=g7



private void ErrorTestFunc()
{
Database db1 =
DatabaseFactory.CreateDatabase("DefaultConnection");
System.Data.IDataReader Dr1 =
db1.ExecuteReader(System.Data.CommandType.Text, "select * from ASPNET_USERS
");
while (Dr1.Read())
{
Database db2 =
DatabaseFactory.CreateDatabase("DefaultConnection");
System.Data.IDataReader Dr2 =
db2.ExecuteReader(System.Data.CommandType.Text, "select * from ASPNET_USERS
");
Dr2.Close();
Dr2.Dispose();
}
Dr1.Close();
Dr1.Dispose();
}

Why do you have a nested data reader?


I did address this when I said


...............................

What is your backend RDBMS? Sql Server? Other?



...............................
 
S

Stefano C.

Hi,
Sorry for this long delay. It is for holydays and an error in notification
configuration.
Yes i have two nested datareader in my class because i use two different
methods created for different purpose.
Keep in mind that that code is just for example. Just a simplification that
reproduce the error.
The real question is...why it work perfectly out of WCF service? It works
fine ina a winform app,for example.

Anyway now i'm tring to implment a better cleaner block as last attampt.
Regards.

About the error the problem is that
 
S

Stefano C.

Additional info... i'm using Sql2008 as backend RDBMS. Anyway sorry but i
don't think your cleaner block can sole this problem. Problem i don't
understand what's your suggestion.
Regards.
 
S

Stefano

I faound wat's the real problem. This is not a WCF fault but a Transaction +
DAAB problem.
Problem dos not arrive using DAAB with WCF but using with Transaction
(configured via attribute in WCF).
so i'm searching information about this problem.
Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top