2006-06-29

"Specified Service Already Exists"

I ran into this problem when creating a setup in .NET and choosed "Repair" at a later stage. The problem was due to that I was creating my own Custom Actions. When doing a "Repair" the custom install action is run as well. To prevent this you need to add: "Not Installed" at the Condition property of the Custom Action.

2006-06-12

Problem - loop through a repeater for controls

I was using ASP.NET, C#, and wanted to auto translate some controls on a Page. I had no problems looping through controls like the GridView but when I tried the Repeater control I ran into problems. No controls or items were found when looping through it.

The problem was that the controls/items were created at a later stage than Page_Load where my function was executed.

I moved my function to Page_PreRender and everything went just fine..

2006-04-30

ToolStrip and it's responsiveness

I had a problem with the new .NET 2.0 component "ToolStrip". The problem appeared when switching between forms within an application by clicking on one of the toolstrip buttions. The first click was not "catched" as an event. This was really annoying and I was near switching to the toolstrip components of Infragistics.

First I found a quick solution. I added the event "MouseHover" and then focused on the toolstrip like this:

Private Sub tolMain_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tolMain.MouseHover
tolMain.Focus()
End Sub

It worked but it seemed unnesseary. I did a quick search on the Internet and I found a post from one who had faced and solved the problem. Read more about it here: http://blogs.msdn.com/rickbrew/archive/2006/01/09/511003.aspx

He hade made a C# example and here is my code, converted to VB.NET:


Imports System.Windows.Forms.ToolStrip
Public Class ToolStripEx
Inherits ToolStrip
Private bolClickThrough As Boolean = False

Public Property ClickThrough() As Boolean
Get
Return bolClickThrough
End Get
Set(ByVal value As Boolean)
bolClickThrough = value
End Set
End Property

Public Sub New()
MyBase.new()
End Sub

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
If bolClickThrough Then
If m.Msg = NativeConstants.WM_MOUSEACTIVATE And m.Result = CType(NativeConstants.MA_ACTIVATEANDEAT, IntPtr) Then
m.Result = CType(NativeConstants.MA_ACTIVATE, IntPtr)
End If
End If
End Sub
End Class

Friend Class NativeConstants
Friend Const WM_MOUSEACTIVATE As UInt32 = 33
Friend Const MA_ACTIVATE As UInt32 = 1
Friend Const MA_ACTIVATEANDEAT As UInt32 = 2
Friend Const MA_NOACTIVATE As UInt32 = 3
Friend Const MA_NOACTIVATEANDEAT As UInt32 = 4
End Class

2006-04-24

Long time no blog

There have been a lot of work on VisualCron lately. There is a clear roadmap but sometimes I get busy on sidetracks - smaller o bigger requests by customers. Luckily, my dad, a professional tester has been there helping with testing and documentation.

On the personal side, I have a lot of things that I look forward to. First, the average temperature is increasing every day. Second, there will be a lot of traveling this year. In the end of May, me and Neda are traveling to Istanbul, Turkey. In July we will travel to Malage in Spain. Later in the autumn, me and my friends are going to London.

I haven't had the time to work with the studio yet. Hopefully there will be more time soon..

2006-01-25

WMI Adventures - "Invalid Class", "Not Found" and "Access Denied"

I was trying to monitor the registry with WMI - Windows Management Instrumentation. I could find almost everything in the namespace "root\CIMV2" for my needs except for registry changes. Those where located in "root\DEFAULT" and did not use the regular WQL polling operator "WITHIN".

I searched for examples on the net using C# or VB.NET. The net was quite dry on this subject. I found some examples but when implementing those I got "Invalid Class". After some testing I found that you need to specify the class in the EventQuery. And the class changes depending on the type of registry query you want todo.

Registry changes are divided in three parts:

RegistryTreeChangeEvent - Monitors changes to a hierarchy of keys.
RegistryKeyChangeEvent - KeyPath Monitors changes to a single key.
RegistryValueChangeEvent - ValueName Monitors changes to a single value.

This is a VB.NET example:

Dim evQuery As New WqlEventQuery()
evQuery.EventClassName = "RegistryValueChangeEvent" <--- here you specify the classname which should match the "tablename" in the querystring evQuery.WithinInterval = New TimeSpan(0, 0, 0, 10, 0) evQuery.QueryString = "SELECT * FROM RegistryValueChangeEvent WHERE hive = '" & _ "HKEY_LOCAL_MACHINE" & "' AND KeyPath = '" & _ "Software\\Activision" &amp;amp; "'" & _ "AND ValueName='mamma'"

So remember to change the EventClassName depending on the tablename.

While testing I also stumbled upon the ManagementException "Not found". This error is due to that there is not match in the WQL. Maybe you have specified the wrong KeyPath or your are missing the double backspace.

The error "Access denied" is however not solved. I am getting the error when using the LIKE operator in WQL. If you have any idea about this the please comment that :)