Dim conn as SqlConnection = MakeSqlConnection()
Try
' do some DB work
conn.Close()
Finally
' following line FAILS if conn is actually nothing
if not conn is Nothing then conn.Dispose()
' this works for some reason
if not conn is Nothing then
conn.Dispose()
end if
End try
---------------------------------
Private Shared Sub CropBitmap(ByVal sourceBitmap As System.Drawing.Bitmap,
ByVal destFilePath As String, ByVal region As System.Drawing.RectangleF)
Dim bitmap As System.Drawing.Bitmap
Dim croppedBitmap As System.Drawing.Bitmap
Dim hRes As Single = bitmap.HorizontalResolution
Dim vRes As Single = bitmap.VerticalResolution
Dim cropRegion As New System.Drawing.RectangleF(region.X * hRes, region.Y
* vRes, region.Width * hRes, region.Height * vRes)
Try
bitmap = sourceBitmap
croppedBitmap = bitmap.Clone(System.Drawing.Rectangle.Round(cropRegion),
Drawing.Imaging.PixelFormat.Format1bppIndexed)
croppedBitmap.Save(destFilePath, System.Drawing.Imaging.ImageFormat.Tiff)
Finally
' ~~~~~~ this FAILS if croppedBitmap is actually nothing:
If Not croppedBitmap is Nothing then croppedBitmap.Dispose()
' ~~~~~~ this WORKS:
If Not croppedBitmap Is Nothing Then
croppedBitmap.Dispose()
End If
End Try
End Sub
--------------------------------
My hypothesis is that the VB compiler is getting into a slightly invalid
state once its hitting the Finally, and writing out incorrect IL code.
-------------------
Eric Newton
C#/ASP developer
er...@cc.ensoft-software.com [remove the first "cc."]
Have a look at what's compiled using "isdasm.exe".
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Run the VB code and step through the Test 2 block and inline IFs, you'll
notice the debugger steps over to the inline IFs true condition but a NOP is
actually run.
--
Eric Newton
C#/ASP Application Developer
er...@cc.ensoft-software.com [remove the first "CC."]
"Eric Newton" <er...@cc.ensoft-software.com> wrote in message
news:OhcGOKHp...@TK2MSFTNGP12.phx.gbl...
> already did that, apparently its a problem maybe with the debugger? the
IL
> code looks correct in both circumstances...
>
>
> --
> Eric Newton
> C#/ASP Application Developer
> er...@cc.ensoft-software.com [remove the first "CC."]
>
> "Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
> news:bobgch$1bt8vl$1...@ID-208219.news.uni-berlin.de...
Right, that's a "known" feature.
--
Armin
Thanks for sharing the results of your research on this topic!
"Its not a bug... its a feature" [tongue in cheek]
--
Eric Newton
APTItude Solutions
ene...@aptic.com.nospam
"Armin Zingler" <az.n...@freenet.de> wrote in message
news:uBnYdgHp...@TK2MSFTNGP12.phx.gbl...