Friday, December 4, 2009

JDI thread evaluations - Exception processing async thread queue

After some debugging Eclipse may throw an async thread exception every time it hits a breakpoint. The message is along the lines of

JDI thread evaluations
Exception processing async thread queue

You can clean this up by removing all watch statements and all breakpoints and restarting Eclipse.

Wednesday, November 11, 2009

Firebird -902 error localhost refused connection

Seems too obvious but you will get this error if you try to Connect after you Stop or Pause your Firebird Server service. More common causes are amply documented on the web - Firewall blocking and Incorrect port # (default is 3050)

Thursday, September 17, 2009

Launching CHM help file from a Java application on Windows

Seems like an obvious need but could not find an example for how to launch a compiled HTML help file from inside a Java JAR application on a Windows machine, so here's one:

String myHelpfile = path + "help.chm";
String[] command = { "hh.exe", myHelpfile };
try {
Process proc = Runtime.getRuntime().exec(command);
} catch (IOException e) {

Friday, August 28, 2009

Removing requirement for NET Framework 3.5 from setup projects

A new setup and deployment project in Visual Basic 2008 will by default require .NET Framework 3.5 on the target machine

If your application targets .NET Framework 2.0 this is a waste of time

To change the requirement right-click on your setup project, select View, Launch Conditions, go to properties of the ".NET Framework" item under the Launch Conditions node and change the Version property to 2.0.50727

Friday, August 14, 2009

How to find the control that generated a postback

Had a little trouble finding a good example of how to identify the control that generated a postback within the page_load

There's a nice article for C#, after a bit of tinkering here's a VB implementation:

Public Function GetPostBackControl(ByVal curPage As Page) As Control

 Dim foundControl As Control
 Dim controlName As String = curPage.Request.Params.Get("__EVENTTARGET")

 If (Not controlName Is Nothing And controlName <> "") Then
  foundControl = curPage.FindControl(controlName)
  ' control causing postback must be a Button or imageButton
  For Each controlName In curPage.Request.Form.AllKeys

   ' image buttons have a ".x" or ".y" appended to name string
   If (controlName.EndsWith(".x") Or controlName.EndsWith(".y")) then
    controlName = controlName.Substring(0, controlName.Length - 2)
   End If

   Dim c As Control = curPage.FindControl(controlName)

   If (TypeOf c Is Button Or TypeOf c Is ImageButton) Then
    'first button we find is the one that caused the postback
    foundControl = c
    Exit For
   End If
 End If

 GetPostBackControl = foundControl

End Function

Friday, July 10, 2009

IIS hyperlinks fail - cannot open an anonymous level security token

Recently upgraded a test machine to Internet Explorer 8. While testing a new deployment today found that hyperlinks created in my web application stopped working. The error icon on the bottom left of the screen said: "Cannot open an anonymous level security token"

The solution from a microsoft community site was to reset DCOM default properties to "Connect/Identify".

After rebooting and reopening the site in IE8 the links now work.

We tinker with DCOM on this test machine quite often and I found it with default properties of "None/Impersonate" - maybe impersonate causes a problem for anon access but I don't remember these problems with IE7. Hopefully this is not a sign the IE8 is going to "UAC" all over the system like Vista did.

Getting version number from a visual basic 2008 web application

Dim versionInfo As String = System.Reflection.Assembly.GetExecutingAssembly().GetName() .Version.ToString()

Obvious in hindsight, but took me a little while to find it

Tuesday, July 7, 2009

Changing the background color of a checkbox at runtime

I wanted to show 3 values in a checkbox ("full", "partial", and "empty") by changing background color of the selected checkbox when state is "partial"

I thought we could simply set the background color property, but that had no effect for me at runtime. It took a while to find how to programatically change background color of a checkbox on a VB web form, finally this post and this post got me close enough.

How to change the color at runtime:

(1) Add CSS style declarations to your form's design view (.aspx page), for example:

.full {
background-color: #fff;
.partial {
background-color: #ccc;

(2) in the form load method add some code like this:

curControl = CType(Page.FindControl(sID), CheckBox)

if (ispartial) then
curControl.Checked = True
curControl.CssClass = "partial"
else if (isfull) then
curControl.Checked = True
curControl.CssClass = "full"

Thursday, June 25, 2009

Visual Studio 2008 IDE memory leak - "Enable error correction suggestions" causes sluggish behavior, freezing, and crashes

Have been experiencing slowdowns, freezing and crashing of the visual basic IDE on a consistent basis for a few days.

I can see memory leaking in megabyte+ chunks within Task Manager each time I type anything in the IDE on a VB code page. With just one file open I can keep the memory growing indefinitely in ~10MB increments by adding any text, erasing it, saving, and then repeating.

The additional memory is not fully recovered so I eventually have to restart the IDE to avoid a crash. I've seen it climb up to 1.4 GB (out of 3 GB). This was not a sustainable way to work.

Almost sure this behavior started after June 2009 windows hotfixes were applied. I had been working primarily in Java/Eclipse the last few months, but intermittenly spent time in the VS2008 IDE producing hotfixes and had not experienced this instability before.

Tried removing Office 2007 (trial) since that was mentioned as a possible issue in a couple of places, but no change. Tried removing MS Works which was recently installed as a "security hotfix" - only to find that is a whole can of worms by itself.

WORKAROUND: What finally seems to have stabilized the IDE is de-selecting the "Enable error correction suggestions" option.

HOW TO: to de-select this option go to Tools, Options, Text Editor, Basic, VB Specific - uncheck the box and hit OK.

If anyone has any better suggestions please feel free to post in comments.

Thursday, April 23, 2009

Using "Zone" as a field alias in SQL query generates getDescription error 80004005

Spent a few minutes on this one and it seemed worth noting. I was trying to run a query joining a few tables using field aliases (e.g. tbl_X.fieldY AS aliasZ) because each table has an fName field that I need to reference.

The query generated an error: IErrorInfo.GetDescription failed with E_FAIL(0x80004005)

At first I thought it as a DCOM permissions issue, since error code 80004005 can indicate an insufficient security permissions when accessing resources using COM. However, it turns out my alias tbl_Zone.fName as Zone" was the problem.

Apparently Zone is a reserved word in this context? Who knew.

Wednesday, March 11, 2009

Checkbox would not check in Firefox while sharing Z-index with other checkboxes

Just debugged a little issue with checkboxes on web forms in Visual Studio 2008 while using Firefox. I have a column of checkboxes that were cloned from a single instance (cut/paste in the text portion of the design view) then distributed vertically by manually editing the top value.

The checkboxes worked fine in IE, but in Firefox I could not get them to change state to Checked. After changing to a unique z index the checkboxes started working again. Interesting.

Wednesday, January 7, 2009

Where to find the Devenv.exe /resetskippkgs command

If you install Visual Studio 2008 Standard Edition after running the VS 2008 Professional 90 day trial you may get a package load failure when you start the Standard environment.

The error message recommends running "devenv /resetskippkgs" from the command line, but no location is specified and the path was not recognized on my PC so the command did not run

For visual studio 2008 the command is found in the C:\Windows\Microsoft.NET\Framework\v3.5 directory. Make sure you have shut down any open instances of VS before running this command. The command will open a new instance, which I closed immediately in order to save the updated settings. No more warnings about packages since then

Installing Visual Studio 2008 Standard after running the VS2008 Professional trial

I could not find anything on this so here's a post to say it was easy to install Visual Studio 2008 Standard edition after running the Visual Studio Professional trial version. So far no trouble working with my web application, windows forms, windows service, and windows DLL projects that were upgraded from VS 2005 using the 2008 Pro trial version.

I installed Standard on day 89 of the trial. When I started the IDE it defaulted to the Pro trial, so I went to Control Panel, Programs & Features (Vista), and selected uninstall on the "Microsoft Visual Studio 2008 Professional - ENU" entry.

That launched an installer looking essentially the same as the VS2008 Standard installer, but with a "maintenance mode" label. Next, selected Add/Remove, and confirmed yes to "remove all of Visual Studio 2008". The warning sounds a bit ominous, but it removes just the Pro version and after that my opened up in Standard just fine. There was a single warning about a package not loading which apparently can be resolved by running devenv with the /resetskippkgs option.

Tuesday, January 6, 2009

New setup project MSI requires .NET Framework 3.5 even though project targets other Framework

If you create a new Setup project in VS2008 for a project targeting Framework 2.0 it will prompt the user to install Framework 3.5 even if it is not needed.

To fix this right-click on the Setup project in the solution explorer, select View, Launch Conditions. Right-click on the ".Net Framework" item, select Properties Window, then select your appropriate framework version (e.g. 2.0.50727)

Next time you build the solution the MSI will require only the appropriate Framework.