GAAnalytics4

2011-09-16

Clipboard Html Okuma Encoding Problemi

Eğer clipboard'dan CF_HTML formatında veri okurken encoding problemi çıkartıyorsa:
Dim cdata As String= Clipboard.GetText(TextDataFormat.Html)

şeklinde okuma yerine
  Dim str As System.IO.MemoryStream = TryCast(Clipboard.GetData("Html Format"),System.IO.MemoryStream)
            If str IsNot Nothing Then
                str.Seek(0, IO.SeekOrigin.Begin)
                Dim sr As New System.IO.StreamReader(str, System.Text.Encoding.UTF8)
                cdata = sr.ReadToEnd
                sr.Close()
            End If

şeklinde değiştirirseniz encoding problemini aşarız.

2011-06-08

SlSvcUtil.exe kullanırken oluşan StackOverflowException


Eğer Silverlight için SlSvcUtil.exe kullanarak bir WCF servisi consume ederken Process is terminated due to StackOverflowException hatası alıyorsanız SlSvcUtil.exe'nin bulunduğu dizine aşağıdaki konfigurasyonu içeren SlSvcUtil.exe.config dosyası oluşturun:

<configuration>
<satelliteassemblies>
<assembly name="SlSvcUtil, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</satelliteassemblies>
</configuration>

2011-06-04

Lambda expressionda kendini(recursive) kullanım


Visual 2008 VB ile gelen Lambda expression ile artık kod içinde istediğimiz yerde Function,Sub kullanabiliyorduk.Örneğin:

Private Sub UCAgac_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim action = Sub()
MessageBox.Show("Deneme")
End Sub
Dim bol = Function(a As Double)
Return a / 4
End Function
End Sub



Eğer bu şekilde tanımlı bir lambda expression kendi içinde çağırmak istediğimizde

Dim bol = Function(a As Double)
If a > 0.0111 Then
Return bol(a / 4)
Else
Return a / 8
End If
End Function
Dim t As New System.Windows.Threading.DispatcherTimer()
t.Interval = TimeSpan.FromMilliseconds(100)
Dim handler = Sub()
If 1 > 0 Then
RemoveHandler t.Tick, handler
End If
End Sub
AddHandler t.Tick, handler
t.Start()

  1. Type of 'bol' cannot be inferred from an expression containing 'bol'

  2. Type of 'handler' cannot be inferred from an expression containing 'handler'


Visual Studio şeklinde bize bir hata verecektir.Sebebi ise lamda expressionlarının açık şekilde
tanımlanmamasıdır.Eğer açık şekilde tanımlarsak:

Dim bol As System.Func(Of Double, Double) = Function(a As Double)
If a > 0.0111 Then
Return bol(a / 4)
Else
Return a / 8
End If
End Function
Dim t As New System.Windows.Threading.DispatcherTimer()
t.Interval = TimeSpan.FromMilliseconds(100)
Dim handler As System.EventHandler = Sub(sender As Object, e As System.EventArgs)
If 1 > 0 Then
RemoveHandler t.Tick, handler
End If
End Sub
AddHandler t.Tick, handler
t.Start()
hata alınmaz.