Answered by:
Error A First Chance Exception Of Type System.data.entitycommandexecutionexception Occurred In System.data.entity.dll

Question
-
I have seen this error for other user's, even in this forum. But not in my particular context. I have built a silverlight reporting application which is using wcf and entity framework for data retrieval. Everything seems to work fine initially but after having run through several reports I get the error above on calls that initial were working. In other words there seems to be some sort of resource issue in my code somewhere. Unfortunately that line is the only error I'm getting back. But I do suspect that the exception itself is coming from somewhere in the following code:
public T GetPatchInventoryByQueryString<T,I>(string queryStr) where T : IList<I> where I : IPatchInventory { EntityConnection econn = new EntityConnection("name=LDMS861Entities1"); try { IList<PatchInventory> patches = _container.Resolve<IList<PatchInventory>>(); if (econn.State == ConnectionState.Closed) econn.Open(); using (econn) { using (EntityCommand scmd = new EntityCommand(queryStr, econn)) { using (EntityDataReader edr = scmd.ExecuteReader(CommandBehavior.SequentialAccess)) { while (edr.Read()) { patches.Add(GetPatchInventoryByDataRecord<PatchInventory>(edr)); } } return (T)patches; } } } finally { if (econn.State == ConnectionState.Open) { econn.Close(); econn.Dispose(); } } }
Monday, August 23, 2010 6:37 PM
Answers
-
Hi,
If you add a breakpoint at the beginning of this method you should be able to step through the method to find exactly where things go wrong. This might give me more information. Also you should add a catch... block that can probably give an Exception with a better explanation.
Please let me know when you have more information.
Regards, Patriek- Proposed as answer by liurong luo Wednesday, August 25, 2010 6:38 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Monday, August 30, 2010 3:36 AM
Monday, August 23, 2010 6:50 PM -
- Proposed as answer by Patriek van Dorp Wednesday, August 25, 2010 11:05 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Monday, August 30, 2010 3:36 AM
Monday, August 23, 2010 6:54 PM
All replies
-
Hi,
If you add a breakpoint at the beginning of this method you should be able to step through the method to find exactly where things go wrong. This might give me more information. Also you should add a catch... block that can probably give an Exception with a better explanation.
Please let me know when you have more information.
Regards, Patriek- Proposed as answer by liurong luo Wednesday, August 25, 2010 6:38 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Monday, August 30, 2010 3:36 AM
Monday, August 23, 2010 6:50 PM -
- Proposed as answer by Patriek van Dorp Wednesday, August 25, 2010 11:05 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Monday, August 30, 2010 3:36 AM
Monday, August 23, 2010 6:54 PM -
By the way,
Here's how you can disable the first chance exception.
Regards, PatriekWednesday, July 9, 2014 11:16 AM