Tuesday, September 30, 2008

Cut and paste is disabled in Remote Desktop session

A quick reminder of the counter-intuitive setting to enable cut and paste functionality on a remote PC during a Remote Desktop Connection sessions.

Open the RDC window to start a connection. Before connecting, cick on Options, select Local Resources tab, and DE-select the "clipboard" checkbox under the heading "select resources you want to use in your remote session".


Now you will be able to use normal cut/paste functionality on the remote PC.

Thursday, September 25, 2008

Timer on a new thread attached to a windows service disappears after 10 minutes

I created a visual basic windows service application in Visual Studio 2005 which needed a timer to fire every 10 seconds. I found an example showing how to attach a timer in a new thread to the service which worked fine during development.

Then I installed on a test system and the timer would fire for 10 minutes and then disappear and the service would stop working. Stopping consistently at ten minutes was a clue.

There was no succinct explanation, but Garbage Collection came up in reference to unattended threads. The timer on a new thread was eligible for GC if it was not referenced periodically. The solution was simple, make the timer handle a global variable, and referencing the handle each time the timer handler invokes.

Public Class My_Scheduler_Service

Dim tDelegate As Threading.TimerCallback
Dim oTimer As System.Threading.Timer

Protected Overrides Sub OnStart(ByVal args() As String)
.....
tDelegate = AddressOf TimerFireEvent ' my timer handler
oTimer = New System.Threading.Timer(tDelegate, Me, 0, iTIME_INTERVAL)

end sub

Public Sub TimerFireEvent(ByVal sender As Object)

Try
'reference timer to avoid Garbage Collection
If (oTimer Is Nothing) Then
System.IO.File.AppendAllText("C:\Log.txt", Now.ToString() & ": oTimer = nothing" & vbCrLf)
Else
System.IO.File.AppendAllText("C:\Log.txt", Now.ToString() & ": oTimer OK" & vbCrLf)
End If
...

Posting this because Garbage collection impact on a new timer thread was not something I saw clearly in documentation or examples.

Thursday, September 11, 2008

Visual Studio 2005 MSI install fails on Vista - "Installation Incomplete"

Built an MSI on the Web Setup Project template in Visual Studio 2005 on my Vista dev machine and tried to install to a Vista Home Premium machine. The MSI quickly stops and says "Installation Incomplete", without any useful feedback.

I created a log file, the fatal error code was 1603 but that didn't lead to much help.

Tried Windows Installer Cleanup Tool, no help. Tried upgrading to Installer 4.5, no help. Finally I remembered a post that mentioned IIS 6 compatibility being required for some MSI packages (http://forums.karamasoft.com/ShowPost.aspx?PostID=6495). I had ignored it since I was building on Vista with IIS7, and installing to Vista with IIS7, but of course....

Went to Control Panel, Programs & Features, Add/Remove Windows Component - turned on all the IIS6 compatibility options and retried the MSI. Installs clean now.

Lesson? I believe since Visual Studio 2005 was released at the time of IIS6 it still relies on the old API, so keep this in mind when installing web setup projects to Vista boxes.

How to create a log file for an MSI install

I built an MSI using a Visual Studio 2005 web setup project. This type of project is a simpler install than a web application project, but there is no way to pick the target folder for the install.

An article explains how to modify an MSI (http://www.codeproject.com/KB/install/ChangeVDirWebSetupProject.aspx), but at the end of the process the new MSI is generating errors trying to install on a Vista Home Premium machine.

I had a bit of trouble generating a log file, so here is the working example:

c:Installs>msiexec /i MyPackage.msi /l* MyLog.txt

this generates a local file log in MyLog.txt

Wednesday, September 10, 2008

Parser Error Message: Could not load type 'WebApplication1.Login'

This type of error popped up when porting a Visual Basic 2003 web project to become a Visual Studio 2005 web application project.

This was due to Webapplication1.dll being installed in wrong folder. Quick fix was to move Webapplication1.DLL from application folder into bin. Refresh the browser and it loads fine.

The longer term fix is in the setup project, right-click, View, File System - then move the DLL from the web app folder into the bin folder