Searching for previous occurrences of this I found this thread, that was fixed in 2015... but we are encountering something extremely similar using Llblgen Pro 5.7.3
cf: https://www.llblgen.com/tinyforum/Thread/23267
code snippets:
public bool PenMove(byte siteId, DateTime date, int fromPenId, int toPenId, int lotId, int head,
Guid transactionId)
{
try
{
using var adapter = new DataAccessAdapter(ConnectionString);
return ActionProcedures.PenMove(siteId, fromPenId, toPenId, date, lotId, head, adapter) > 0;
}
catch (Exception e)
{
throw e.ToBusinessException();
}
}
If there is any sql exception within the stored procedure call, I see that exception in the generated code for ActionProcedures in my VS2022 debug IDE on the call.Call()
public static int PenMove(System.Byte siteId, System.Int32 fromPenDgId, System.Int32 toPenDgId, System.DateTime date, System.Int32 lotDgId, System.Int32 intHeadToMove, IDataAccessCore dataAccessProvider)
{
using(var call = CreatePenMoveCall(dataAccessProvider, siteId, fromPenDgId, toPenDgId, date, lotDgId, intHeadToMove))
{
int toReturn = call.Call();
return toReturn;
}
}
continuing the debug session after that exception is shown there, which should result in the same exception being caught by our try catch, we only get
"The SqlParameter is already contained by another SqlParameterCollection"
The SqlParameter is already contained by another SqlParameterCollection.
at System.Data.SqlClient.SqlParameterCollection.Validate(Int32 index, Object value)
at System.Data.SqlClient.SqlParameterCollection.AddRange(Array values)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.CreateStoredProcedureCallCommand(String storedProcedureToCall, DbParameter[] parameters)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.CallActionStoredProcedure(String storedProcedureToCall, DbParameter[] parameters)
at SD.LLBLGen.Pro.ORMSupportClasses.StoredProcedureCall.Call()
at ITS.feedIT.Entities.DatabaseSpecific.ActionProcedures.PenMove(Byte siteId, Int32 fromPenDgId, Int32 toPenDgId, DateTime date, Int32 lotDgId, Int32 intHeadToMove, IDataAccessCore dataAccessProvider)
I have reproduced this with forcing an exception in my stored procedure, just to eliminate anything else going on there:
alter PROCEDURE [dbo].[PenMove]
@siteId tinyint,
@fromPenDgId int,
@toPenDgId int,
@date DateTime,
@lotDgId int,
@intHeadToMove int
AS
declare @ret int
select @ret = 1 / 0
oddly if I disable 'Just my code' in VS debug options, I then do get the correct exception propagated.
These behaviors repeat every time I test this.
I am using VS2022 17.4.3 (I'm avoiding 17.5 for now as there is a hot reload bug in that)
Is this something in your code that is causing this in debug sessions ?
Thanks
Simon