Sunday, November 24, 2013

Getting Citrix Receiver Working on Fedora 19

  1. Download the Citrix Receiver in RPM format here:
  2. As sudo or root, issue a `yum install ICAClient*.rpm`.
  3. Click on the .ica link in your xenapp citrix website. When prompted to open or download the .ica file, select download.
  4. Run `/opt/Citrix/ICAClient/ launch.ica` in the directory where launch.ica was downloaded to.
  5. If you see error messages like, "Error while loading shared library : : can not open shared object file", issue a ` yum install libpng12.i686 libpng12-devel.i686`. 
  6. Go back to your Citrix website, and click on the .ica link again. This time instead of downloading it, select open with, and choose, "/opt/Citrix/ICAClient/".
  7.  The Citrix receiver will now complain about  you not having a trusted certificate. You will need to find the certificate needed and place it in the following folder, "/opt/Citrix/ICAClient/keystore/cacerts/". For example if you need the Go Daddy Class 2 certificate, go to the following site and download it into the cacerts folder; You can also export the certificate from Firefox (Preference -> Advanced -> View Certificates) or if you have a working Windows computer export it following these instructions.
  8. Citrix Receiver should now work. (If you encounter issues with sound try `yum install alsa-lib.i686` however I haven't bothered with sound yet)

Tuesday, September 24, 2013

VB.Net Cross Thread Events in WinForms

Today I quickly did a proof of concept on integrating a third part component into a winforms application and had to figure out how to raise events on the Windows Forms UI thread from a different one. There are plenty of examples of doing this in C# but they didn't quite translate to VB.Net.

Although a BackgroundWorker may have worked I had some more complex requirements. Therefore I slightly tweaked a C# cross thread example on stackoverflow and combined it with another example of building a custom event. Here is what I came out with. I have to investigate better ways of doing this but since there is a lack of any VB.Net examples I thought I would post one.

Imports System.ComponentModel
Imports System.Threading

Public Class CrossThreadingExample

    Private dummyThread As Thread

    Private ReadOnly crossThreadEventList As New List(Of CrossThreadEventHandler)

    Public Delegate Sub CrossThreadEventHandler(sender As Object, e As CrossThreadEventArgs)

    Public Custom Event CrossThreadNotification As CrossThreadEventHandler

        AddHandler(handler As CrossThreadEventHandler)
        End AddHandler

        RemoveHandler(handler As CrossThreadEventHandler)
        End RemoveHandler

        RaiseEvent(sender As Object, e As CrossThreadEventArgs)
            For Each del In Me.crossThreadEventList
                Dim synchronizedInvoke As ISynchronizeInvoke = DirectCast(del.Target, ISynchronizeInvoke)

                If synchronizedInvoke IsNot Nothing AndAlso synchronizedInvoke.InvokeRequired Then
                    synchronizedInvoke.Invoke(del, New Object() {sender, e})
                    del.DynamicInvoke(New Object() {sender, e})
                End If

        End RaiseEvent

    End Event

    Public Sub Start()
        Me.dummyThread = New Thread(AddressOf DoWork)
        Me.dummyThread.IsBackground = True
    End Sub

    Public Sub Cancel()
    End Sub

    Private Sub DoWork()
        Dim i As Integer = 0
        While i < Integer.MaxValue
            i += 1
            If i Mod 10 = 0 Then
                RaiseEvent CrossThreadNotification(Me, New CrossThreadEventArgs(i))
            End If

        End While
    End Sub

End Class

Public Class CrossThreadEventArgs
    Inherits EventArgs

    Public Property NumberDivisibleBy10 As Integer

    Public Sub New(number As Integer)
        Me.NumberDivisibleBy10 = number
    End Sub

End Class

And here is an example of using it on a Windows Form where a label gets updated with values divisible by 10.

Public Class ExampleForm

    Private WithEvents crossThreadingExample As CrossThreadingExample

    Public Sub New()
        Me.crossThreadingExample = New CrossThreadingExample()
    End Sub

    Public Sub ChangeLabel(sender As Object, e As CrossThreadEventArgs) Handles crossThreadingExample.CrossThreadNotification
        Me.LabelCounter.Text = e.NumberDivisibleBy10.ToString()
    End Sub

    Protected Overrides Sub OnClosing(e As System.ComponentModel.CancelEventArgs)
    End Sub

End Class

Sunday, July 28, 2013

Querying IIS Log File Information Easily

Microsoft has a command line tool called LogParser that can easily be used to execute SQL statements against log files. The tool is extremely handy when there is problem with a web service or site hosted by IIS.

For example to see if a rogue consumer of your web service is doing something silly like looping through and flooding it with calls you can query the most called web service by IP address by issuing:

.\LogParser.exe -i:W3C "
    date as date,  
group by
   count(*) > 500000
" -rtp:-1
This will return a nicely formatted result like so:
COUNT(ALL *) date         cs-uri-stem                   c-ip    
------------ ----------   ----------------------------- ------------- 
510832       2013-07-11   /ExampleServices/Test.asmx  
535199       2013-07-11   /ExampleServices/Example.asmx 
Log parser is typically installed in: C:\Program Files (x86)\Log Parser 2.2

Sunday, June 9, 2013

Getting the Lenovo Yoga wireless driver working in Fedora 18

If you are like me you installed Fedora 18 off the live CD only to find that you can't do anything because the wireless card does not work by default.

To get wireless working the first step is to install the build tools needed to install the driver. The easiest way to do this is to download the install DVD to a USB thumb drive. Once you plug it into the Yoga, Fedora will mount the drive automatically. Figure out where it mounted by going to Dolphin or whatever file manager you use and viewing the path to the drive.

Now go into your yum repos and temporary change the yum repository to point to the live dvd image.
[richie@localhost ~]$ su -
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# gedit fedora.repo

change from
name=Fedora $releasever - $basearch
name=Fedora $releasever - $basearch
Next disable the Fedora updates repo by setting enabled to 0 in the fedora-updates.repo file. You can also just issue a yum --disablerepo command. Remember to re-enable it once you are done.
name=Fedora $releasever - $basearch - Updates

Now issue a `yum install make gcc kernel-header kernel-devel cpp perl`

Once yum has installed all the packages needed we can finally download the Realtek driver and copy it over to the Lenovo Yoga via a USB thumb drive. The driver is located here:

After extracting the driver go into the driver folder and issue the command, `make && make install`. If all goes well restart your Yoga and wireless should automatically work.

Make sure to re-enable the fedora-updates.repo by setting enabled=1.

Update 11/17/2013: Please note that whenever you perform a yum update and a new kernel is installed you will need to re-perform a `make && make install` on the wireless driver. Also, the last time I updated my kernel, the make failed. I fixed the failure by downloading a more recent version of the driver: