CAPTCHA i VB.NET kode problem.
HejJeg har taget denne CAPTCHA image for .Net in C-Sharp og oversat den til VB.Net som Code_Begind.
http://www.mbarrick.com/blog/d6plinks/20061221-01
Hvis jeg køre siden/scriptet, så kan jeg se siden men den viser ikke et CAPTCHA image.
Hvis jeg kigger i min kode i VS2005 så kan jeg se en fejl ang. "System.Threading.Interlocked.Decrement(fontSize)" i min "TuringImage.aspx.vb kode.
Fejlen ang. denne linje er:
Overload resolution failed because no accessible 'Decrement' can be called without a narrowing conversion:
'Public Shared Function Decrement(ByRef location As Long) As Long': Argument matching parameter 'location' narrows from 'Single' to 'Long'.
'Public Shared Function Decrement(ByRef location As Integer) As Integer': Argument matching parameter 'location' narrows from 'Single' to 'Integer'.
min kode er:
Dim size As SizeF
Dim fontSize As Single = rect.Height + 1
Dim font As Font
Do
System.Math.Max(System.Threading.Interlocked.Decrement(fontSize), fontSize + 1)
font = New Font(familyName, fontSize, FontStyle.Bold)
size = g.MeasureString(imageText, font)
Loop While size.Width > rect.Width
Dim format As StringFormat = New StringFormat
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center