|
Post by holisticdeveloper on Feb 23, 2011 0:54:35 GMT -5
It seems that use of the StringBuilder class is causing an access violation in my application when it shuts down. This is very reproducible in my app, but I can't get it to reproduce in a standalone application.
I have a function in a class library that executes the following code:
Dim QueryString As StringBuilder Set QueryString = New StringBuilder QueryString.Append "sgMaximumWalkingDistanceGetFromClientIdTripdate @ClientId = " QueryString.Append ClientID I have left out the rest of the code from this function because the access violation will occur even if the rest of the code is commented out.
A particular execution path through my app calls this function, and then if the user exits the application immediately afterword, the application throws an access violation.
Interestingly, if I change the last line to the following, the crash does not occur:
QueryString.Append CStr(ClientID) (note that the ClientID variable is a long)
Any thoughts on why this might be happening?
|
|
|
Post by Kelly Ethridge on Mar 6, 2011 14:21:31 GMT -5
I can't reproduce this error with the following code:
Option Explicit Public sb As New StringBuilder Public l As Long
Public Sub Main() l = 1234 sb.Append "words: " sb.Append l Console.WriteLine sb.ToString Console.ReadKey End Sub
Can you provide a complete example that reproduces this error?
Thank You, Kelly
|
|
|
Post by holisticdeveloper on Mar 21, 2011 17:14:49 GMT -5
It seems to be some odd interaction with the WebBrowser control from Microsoft. Here is some code to reproduce the problem (note that I can only get this to crash when running as a compiled app on Windows XP). With this code, doing the following will repro: - Start compiled app.
- Wait for webrowser control to load Google
- Click the StringBuilder button.
- Close the app.
After that, the access violation occurs as the app is shutting down. Project1.vbp: Type=Exe Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation Object={EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0; ieframe.dll Reference=*\G{14CF02DE-3978-4CCB-9114-674233159946}#2.1#0#..\ADEPT-NYCT\dev\ITP\lib\VBCorLib.dll#VB.EXT: VBCorLib 2.3 Form=Form1.frm IconForm="Form1" Startup="Form1" HelpFile="" Title="StringBuilderCrash" ExeName32="StringBuilderCrash.exe" Command32="" Name="StringBuilderCrash" HelpContextID="0" CompatibleMode="0" MajorVer=1 MinorVer=0 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 VersionCompanyName="" CompilationType=0 OptimizationType=0 FavorPentiumPro(tm)=0 CodeViewDebugInfo=0 NoAliasing=0 BoundsCheck=0 OverflowCheck=0 FlPointCheck=0 FDIVCheck=0 UnroundedFP=0 StartMode=0 Unattended=0 Retained=0 ThreadPerObject=0 MaxNumberOfThreads=1 DebugStartupOption=0
Form1.frm: VERSION 5.00 Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "ieframe.dll" Begin VB.Form Form1 Caption = "Form1" ClientHeight = 6675 ClientLeft = 120 ClientTop = 420 ClientWidth = 11385 LinkTopic = "Form1" ScaleHeight = 6675 ScaleWidth = 11385 StartUpPosition = 3 'Windows Default Begin VB.CommandButton stringBuilderButton Caption = "String Builder" Height = 495 Left = 480 TabIndex = 1 Top = 5160 Width = 1815 End Begin SHDocVwCtl.WebBrowser WebBrowser1 Height = 4215 Left = 480 TabIndex = 0 Top = 360 Width = 10335 ExtentX = 18230 ExtentY = 7435 ViewMode = 0 Offline = 0 Silent = 0 RegisterAsBrowser= 0 RegisterAsDropTarget= 1 AutoArrange = 0 'False NoClientEdge = 0 'False AlignLeft = 0 'False NoWebView = 0 'False HideFileNames = 0 'False SingleClick = 0 'False SingleSelection = 0 'False NoFolders = 0 'False Transparent = 0 'False ViewID = "{0057D0E0-3573-11CF-AE69-08002B2E1262}" Location = "" End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit
Private Sub Form_Load() WebBrowser1.Navigate "http://www.google.com/" End Sub
Private Sub stringBuilderButton_Click() Dim clientID As Long clientID = 628507
Dim QueryString As StringBuilder Set QueryString = New StringBuilder QueryString.Append "sgMaximumWalkingDistanceGetFromClientIdTripdate @ClientId = " QueryString.Append clientID End Sub
|
|
|
Post by Kelly Ethridge on Mar 29, 2011 12:51:30 GMT -5
|
|
|
Post by holisticdeveloper on Mar 30, 2011 13:13:00 GMT -5
Hooray! This version does seem to fix the issue, both in my sample and in my actual application. However, I did notice that the .dll is not binarily compatible with the 2.3.0.0 version. Several IIDs have new GUIDs: - ArrayListStatic
- BigInteger
- BigIntegerStatic
- CDateTimeStatic
- Constructors
- StaticClasses
- TimeSpanStatic
Would it be possible to get an official release, or to see the changes to the source that I could compile myself? Thanks so much!
|
|
|
Post by Kelly Ethridge on Mar 30, 2011 14:29:51 GMT -5
|
|
|
Post by holisticdeveloper on Mar 31, 2011 18:08:45 GMT -5
The binary compatibility seems to be perfect on this one! Thanks so much for your help!
|
|