The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral
icelava wrote:Inheriting from some other base class? Looks like a data layer class; what if executed outside of ASP.NET (e.g. Console presentation layer)?
icelava wrote:Other than the HovelContext class, i do not see why the vg_sys_ms_db_Accounts has affinity to ASP.NET. This makes isolated testing more difficult.
icelava wrote:I also do not see why you have a need to pass in by reference what seems to already be passed by reference by default. Unless you tell me Data.SQLConnectionBlock is a struct instead of a class/object, which case passing by reference is correct (since structs being value types are copied and not referenced).
icelava wrote:I don't know about VB standards, but "struct" is the keyword identifier for declaring a struct type, so looking at your declaration of a class called Struct has really confused me. Recommend naming it to something more meaningful, e.g. TrackerCollection.
icelava wrote:What does ResetTrackers() do? Why is there a need to "Reset" a newly created object? Are "trackers" stored in an ArrayList? Have you attempted to step trace to reveal which line blows that exception?
choongseng wrote:Wait a minute.... I forgot to check out the Trace.axd, I think I check before, but no idea what's the outcome already, maybe the message is more or less the same.
icelava wrote: choongseng wrote:Wait a minute.... I forgot to check out the Trace.axd, I think I check before, but no idea what's the outcome already, maybe the message is more or less the same.I'm not referring to ASP.NET Trace. Debug the web application instead; Set a breakpoint at the constructor and step through it.
choongseng wrote:This is another same error, raised at different location:System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Collections.ArrayList.Add(Object value) at Seacon.eBiz.Web.Controls.TabbedPanel..ctor() in C:\Development\Visual Studio Projects\eBiz Framework\eBiz.Web\Web.Controls\TabbedPanel.vb:line 24
public up_vg_ms_User_Access_Agent_Sel(SQLConnectionBlock ConnBlock) : base(ref ConnBlock)
{
up_vg_ms_User_Access_Agent_Sel.__ENCList.Add(new WeakReference(this));
base.add_PreExecuteEvent(new StoredProcedureBaseClass<up_vg_ms_User_Access_Agent_Sel>.PreExecuteEventEventHandler(this, (IntPtr) this.PreExecute));
base.add_PostExecuteEvent(new StoredProcedureBaseClass<up_vg_ms_User_Access_Agent_Sel>.PostExecuteEventEventHandler(this, (IntPtr) this.PostExecute));
}My original code is as below:
Public Class up_vg_ms_User_Access_Agent_Sel
Inherits Seacon.eBiz.Data.SQLSilo.StoredProcedureBaseClass(Of Seacon.eBiz.Data.SQLSiloStruct.up_vg_ms_User_Access_Agent_Sel)
Public Shadows Event PreExecuteEvent As System.EventHandler
Public Shadows Event PostExecuteEvent As System.EventHandler
Public Sub New(ByVal ConnBlock As Seacon.eBiz.Data.SQLConnectionBlock)
MyBase.New(ConnBlock)
AddHandler MyBase.PreExecuteEvent, AddressOf Me.PreExecute
AddHandler MyBase.PostExecuteEvent, AddressOf Me.PostExecute
End Sub
And the Base class is as below:
Public MustInherit Class StoredProcedureBaseClass(Of boClass As {New})
Protected SPCommand As SQLCommandBlock
Public Params As boClass
Protected Event PreExecuteEvent()
Protected Event PostExecuteEvent()
Public Sub New(ByRef ConnBlock As SQLConnectionBlock)
' Construct a new instance of boClass
MyClass.Params = New boClass()
MyClass.SPCommand = ConnBlock.GetCommandOperation()
MyClass.SPCommand.CommandType = CommandType.StoredProcedure
MyClass.SPCommand.CommandText = GetType(boClass).Name
Well, the case is closed! finally and the finding is simple because then the code is compiled under debug mode, the compiler emit the additional reference for debugger use. And after I've compile it with Release mode, the line is gone!
And the issue of the error is due to the fact that the ArrayList (__ENCList, *Add) is not tread safe.
The issue spend me one incident support ticket and many thanks to Li, who follow up the case.
The lesson learned is ALWAYS use Lutz's reflector tool to find out what is going on FIRST when there's weird bugs.
Hope this will be a useful resource for you guys to refer to, thanks icelava for some hints on the issue, the advice is correct, just that I should have used the reflector instead of looking at source code.
Cheers!
*Edited: it is the thread-not-safe Add method which runs on the static arraylist causes the exception.
icelava wrote:Does that happen to be a VB-only compiler percularity? ;-)Having used C# for so long, I've never encountered such a problem using domain and data layer objects. Debug mode or not. (Nope I did not peek into decompiled assemblies; not enough time)
public virtual int Add(Object value) { if (_size == _items.Length) EnsureCapacity(_size + 1); _items[_size] = value; _version++; return _size++;}
public override int Add(Object value) { lock(_root) { return _list.Add(value); }}