I found a memory leak which occurs when using the Design() method of StiReport. After closing the report designer the instance StiDesignerControl is sill alive. This is caused by an event handler to the static event GoToCode of the StiReportChecker class.
The following code is a temporary solution to free up the report designer. I'm using the static event StiDesigner.ClosingDesigner for this purpose:
Code: Select all
Private Shared Sub StiDesigner_ClosingDesigner(sender As Object, e As CancelEventArgs)
Dim stiDesignerControl As StiDesignerControl = DirectCast(sender, StiDesignerControl)
Dim fieldInfo As FieldInfo = GetType(Stimulsoft.Report.Design.Check.StiReportChecker).GetField("GoToCode", BindingFlags.Static Or BindingFlags.NonPublic)
If fieldInfo IsNot Nothing Then
Dim eventbindings As EventHandler = TryCast(fieldInfo.GetValue(Nothing), EventHandler)
If eventbindings IsNot Nothing Then
For Each d As System.Delegate In eventbindings.GetInvocationList()
If Object.ReferenceEquals(d.Target, stiDesignerControl) Then
Dim eventInfo As EventInfo = GetType(Stimulsoft.Report.Design.Check.StiReportChecker).GetEvent("GoToCode", BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Static)
If eventInfo IsNot Nothing Then
Dim methodInfo As MethodInfo = eventInfo.GetRemoveMethod(True)
If methodInfo IsNot Nothing Then
methodInfo.Invoke(Nothing, {d})
End If
End If
End If
Next
End If
End If
End Sub
Thank you,
Markus