The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for 2009

Delphi – hardcore debugging the intialization of your app, dlls and packages

Posted by jpluimers on 2009/10/15

Recently we got involved with a client having a large and complex application that (historically) consists of

  1. A main .EXE that loads
  2. Many DLLs
  3. Underlying BPLs

One of the biggest problems is debugging the startup sequence.
Somehow, when the Delphi IDE loads DLLs in the initialization sequences of units, it looses its ability symbol tables.

This article describes a few tips on how to debug those, especially where to put breakpoints.
Read the rest of this entry »

Posted in Conference Topics, Conferences, Debugging, Delphi, Development, Event, Software Development | 3 Comments »

Te Waka o Delphi · Absolute for Beginners

Posted by jpluimers on 2009/10/15

Jolyon Smith just published a great article about using the absolute keyword in Delphi.

When used with care (just like the with or goto keywords), absolute can make your code much easier to maintain.

Recommended reading!

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Ancient history – found back one of my earliest email messages dated in februari 1989!

Posted by jpluimers on 2009/10/12

I found back one of my earliest mail messages: it is dated back in februari 1989.

Wow – ain’t search engines nice!

Today, messages like those seem totally irrelevant.

But back then, getting in touch with other people through email could be a real challenge.

The internet was forming (out of UUNET, DECnet, BITNET, Usenet, EARN, ARPANET and others), and not everything was completely interconnected yet, let alone connected on-line 24/7.
For instance, newsgroups were limited to the usenet portion of the internet, and not available on the bitnet portion. Read the rest of this entry »

Posted in //e, About, Apple, Apple Pascal, Apple ][, DEC Pascal, Development, History, Pascal, Personal, Power User, Software Development, UCSD Pascal | 9 Comments »

C# / .NET – setting or clearing the Password Never Expires flag for a user

Posted by jpluimers on 2009/10/11

Recently, I had to change the “Password Never Expires” flag for some users on Windows systems.

In the past, there used to be a netuser tool available from WindowsITPro where you could use the pwnexp flag to set or clear that flag.
That tool seems to be vanished, so I was searching for alternatives.

Most alternatives I found depend on some  kind of scripting, or the use of the WMIC WMI command line interface: that was “out” because this particular setup is running on Windows XP Embedded, which is trimmed down very much.
The only C# example I found was on CodeProject, but it does

  • not take into account the existing flags correctly,
  • have  hard coded literals without any references where they are from,
  • use bit flag arithmetic without letting the C# compiler do its magic with enums,
  • use a call to the deprecated  InvokeGet method,
  • use the Invoke(“Put”, … way of calling that so many people use (which actually should have been an – also deprecated – InvokeSet method),
  • use COM Interop

Hence the solution below:
C#, with the proper ADS_USER_FLAG_ENUM enum from the MSDN documentation and no COM Interop, it also moves all literals to constants.

Read the rest of this entry »

Posted in .NET, C#, C# 2.0, CommandLine, Development, Software Development, XP-embedded | Leave a Comment »

Vista SP2 update: error E_FAIL(0x80004005) caused by SYSHIPER 0x80071a91- solved!

Posted by jpluimers on 2009/10/08

It took me almost 2 days to find out the cause of this one:

When performing a Service Pack 2 update on Vista (in this case a machine that was upgraded from Vista Home to Vista Ultimate), I would always get this very descriptive error message:

E_FAIL (0x80004005)

This is the relevant portion of the CBS.LOG file (%SystemRoot%\Logs\CBS\CBS.log):

2009-10-08 12:50:16, Info CSI 000008d2 Begin executing advanced installer phase 38 (0x00000026) index 1500 (0x000005dc) (sequence 1539)
Old component: (null)
New component: Microsoft-Windows-VistaServicePack-SysHiper-SP1, Version = 6.0.6002.18005, pA = PROCESSOR_ARCHITECTURE_INTEL (0), Culture neutral, VersionScope = 1 nonSxS, PublicKeyToken = {l:8 b:31bf3856ad364e35}, Type neutral, TypeName neutral, PublicKey neutral
Install mode: install
Installer ID: {81a34a10-4256-436a-89d6-794b97ca407c}
Installer name: [15]"Generic Command"
2009-10-08 12:50:16, Info CSI 000008d3 Performing 1 operations; 1 are not lock/unlock and follow:
LockComponentPath (10): flags: 0 comp: {l:16 b:95113b1f0548ca013e07000004058805} pathid: {l:16 b:95113b1f0548ca013f07000004058805} path: [l:206{103}]"\SystemRoot\WinSxS\x86_microsoft-windows-syshiper_31bf3856ad364e35_6.0.6002.18005_none_77fb27ec5025e18b" pid: 504 starttime: 128994722438561151 (0x01ca480440d9bd7f)
2009-10-08 12:50:16, Info CSI 000008d4 Calling generic command executable (sequence 53 (0x00000035)): [115]"C:\Windows\WinSxS\x86_microsoft-windows-syshiper_31bf3856ad364e35_6.0.6002.18005_none_77fb27ec5025e18b\syshiper.exe"
CmdLine: [211]""C:\Windows\WinSxS\x86_microsoft-windows-syshiper_31bf3856ad364e35_6.0.6002.18005_none_77fb27ec5025e18b\syshiper.exe" /install:VistaSP1-KB936330~31bf3856ad364e35~x86~~6.0.0.18000 /hide /permanent /ignorenotexist"
2009-10-08 12:50:17, Info CSI 000008d5 Done with generic command 53 (0x00000035); CreateProcess returned 0, CPAW returned S_OK
Process exit code 0 resulted in success? TRUE
Process output: [l:358 [358]"SYSHIPER: Initialized with following command parameters: /install:VistaSP1-KB936330~31bf3856ad364e35~x86~~6.0.0.18000 /hide /permanent /ignorenotexist

SYSHIPER: Failed with error hr: 0x80070002

SYSHIPER: Failed to open registry key for read

SYSHIPER: CBS key does not exist and ignoring operation for VistaSP1-KB936330~31bf3856ad364e35~x86~~6.0.0.18000

"]
2009-10-08 12:50:17, Info CSI 000008d6 Performing 1 operations; 1 are not lock/unlock and follow:
LockComponentPath (10): flags: 0 comp: {l:16 b:951c4e1f0548ca014007000004058805} pathid: {l:16 b:951c4e1f0548ca014107000004058805} path: [l:206{103}]"\SystemRoot\WinSxS\x86_microsoft-windows-syshiper_31bf3856ad364e35_6.0.6002.18005_none_77fb27ec5025e18b" pid: 504 starttime: 128994722438561151 (0x01ca480440d9bd7f)
2009-10-08 12:50:17, Info CSI 000008d7 Calling generic command executable (sequence 54 (0x00000036)): [115]"C:\Windows\WinSxS\x86_microsoft-windows-syshiper_31bf3856ad364e35_6.0.6002.18005_none_77fb27ec5025e18b\syshiper.exe"
CmdLine: [211]""C:\Windows\WinSxS\x86_microsoft-windows-syshiper_31bf3856ad364e35_6.0.6002.18005_none_77fb27ec5025e18b\syshiper.exe" /install:VistaSP1-KB936330~31bf3856ad364e35~x86~~6.0.1.18000 /hide /permanent /ignorenotexist"
2009-10-08 12:50:17, Info CSI 000008d8 Performing 1 operations; 1 are not lock/unlock and follow:
LockComponentPath (10): flags: 0 comp: {l:16 b:951c4e1f0548ca014207000004058805} pathid: {l:16 b:951c4e1f0548ca014307000004058805} path: [l:234{117}]"\SystemRoot\WinSxS\x86_microsoft.windows.s..ation.badcomponents_31bf3856ad364e35_6.0.6001.18000_none_3891bf6bc31ec194" pid: 504 starttime: 128994722438561151 (0x01ca480440d9bd7f)
2009-10-08 12:50:17, Info CSI 000008d9 Creating NT transaction (seq 1), objectname [6]"(null)"
2009-10-08 12:50:17, Info CSI 000008da Created NT transaction (seq 1) result 0x00000000, handle @0x6b20
2009-10-08 12:50:17, Info CSI 000008db@2009/10/8:10:50:17.182 CSI perf trace:
CSIPERF:TXCOMMIT;5
2009-10-08 12:50:17, Error CSI 000008dc (F) Done with generic command 54 (0x00000036); CreateProcess returned 0, CPAW returned S_OK
Process exit code 6801 (0x00001a91) resulted in success? FALSE
Process output: [l:287 [287]"SYSHIPER: Initialized with following command parameters: /install:VistaSP1-KB936330~31bf3856ad364e35~x86~~6.0.1.18000 /hide /permanent /ignorenotexist

SYSHIPER: Failed with error hr: 0x80071a91

SYSHIPER: Failed to open registry key for write

SYSHIPER: Failed to backup registry key

"][gle=0x80004005]
2009-10-08 12:50:17, Info CSI 000008dd@2009/10/8:10:50:17.182 CSI Advanced installer perf trace:
CSIPERF:AIDONE;{81a34a10-4256-436a-89d6-794b97ca407c};Microsoft-Windows-VistaServicePack-SysHiper-SP1, Version = 6.0.6002.18005, pA = PROCESSOR_ARCHITECTURE_INTEL (0), Culture neutral, VersionScope = 1 nonSxS, PublicKeyToken = {l:8 b:31bf3856ad364e35}, Type neutral, TypeName neutral, PublicKey neutral;240239
2009-10-08 12:50:17, Error CSI 000008de (F) Failed execution of queue item Installer: Generic Command ({81a34a10-4256-436a-89d6-794b97ca407c}) with HRESULT HRESULT_FROM_WIN32(14109). Failure will not be ignored: A rollback will be initiated after all the operations in the installer queue are completed; installer is reliable (2)[gle=0x80004005]
2009-10-08 12:51:08, Info CSI 000008df End executing advanced installer (sequence 1539)
Completion status: HRESULT_FROM_WIN32(ERROR_ADVANCED_INSTALLER_FAILED)

Since the install and rollback of SP2 takes a very long time, it took me almost 2 days to find out the cause:

All normal solutions for issues with 0x80004005, 0x80070002 or 0x80071a91 failed.
I finally found the solution in a thread on vistax64.com.

This registry key was missing:

HKLM\Software\Microsoft\Windows\CurrentVersion\SysHiper

After adding that key in RegEdit, SP2 installed fine (and much faster too).

Many thanks user veldthui!

Back to normal work!

–jeroen

Posted in Development, Vista | 13 Comments »

UI design – required combobox field that only has ‘Other’ as a valid selection…

Posted by jpluimers on 2009/10/01

Sometimes I wonder what people were thinking when they developed a particular part of their user interface.

Look at thecombobox on the right (it is part of an ASPX page, but could have been in any kind of technology):

  • “Job Role” is required
  • “Select One” is an invalid choice
  • “Other” is the only valid choice left

I’d love to know what they are going to do with all this “Other” information…

–jeroen

Posted in Development | Leave a Comment »

.NET – getting text/html in stead of text/xml on your SOAP calls?

Posted by jpluimers on 2009/09/29

Recently, we got this on a project:

inner=System.InvalidOperationException: Client found response content type of ‘text/html;charset=utf-8’, but expected ‘text/xml’.
The request failed with an empty response.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)


Usually this means that the request did not get passed from the WebServer to the actual SOAP layer.
In this particular case it was an overly active ISA admin that had blocked the access to the underlying SOAP Web Service.

–jeroen

Posted in Development, SOAP/WebServices | Leave a Comment »

Turbo Power projects finally coming alive again? Nick Hodges is now tpsfadmin on SourceForge – DelphiFeeds.com

Posted by jpluimers on 2009/09/29

Nick Hodges just posted he has become the tpfsadmin on sourceforge: the administrative account for the Turbo Power tools and libraries.

It is not an officially sponsored Embarcadero thing, but at best semi official.

However, it is an admirable step into getting the Turbo Power tools and libraries updated in one central place again.

Those tools include OnGuard, Orpheus, SysTools, FlashFiler, B-TreeFiler, Async Professional and many others.

So if you have your own fork of any of the Turbo Power code from sourceforge, then please drop Nick a note.

Many thanks to Nick!

–jeroen

Posted in .NET, Database Development, Delphi, Development, Software Development, Source Code Management, SourceForge, Web Development | 6 Comments »

Delphi – record and class helpers: an overview of useful links

Posted by jpluimers on 2009/09/28

At the EKON13 conference, I will be presenting a talk about record and class helpers.

This morning, my laptop did “beeeeeeep beep beep” followed by a deadly silence.
It will take a while before my spare laptop arrives at the hotel and my Vista and VM’s are working again.
So I needed to redo some of my preparations to make sure that I can do a ‘plan B’ if restoring on the spare laptop fails.

Hence below a list of useful links, not yet in a particular order, but it saves you browsing through search engine results sifting the good from the not so good info.

Posted in .NET, .NET CF, Conferences, Delphi, Development, EKON, Event, Software Development | Leave a Comment »

SQL Server notes

Posted by jpluimers on 2009/09/25

Sitting in on Maciej Pilecki’s BASTA! 2009 session on “Advanced SQL Server Troubleshooting” is fun.

First of all it gives a good overview of many topics for which information usually is spreaded.

And there are many new things, for instance some of them about login failures:

Understanding “login failed” – the “state” part is important!

State=16 is undocumented, it can mean that the Administrator Studio is not being run with “Administrative Privileges” (UAC!) under Vista or Windows 7, or you are not allowed to login to the particular database.

Some other useful links

How to use Kerberos authentication in SQL Server (KB 319723).

Cannot create SSPI context (KB 811889).

DMV: Dynamic Management Views.
Sample:

select *
from sysobjects
where name like 'dm_%'
order by name

select *
from sys.dm_os_sys_info

When a LOG file is missing, state_desc in the below query will show ‘RECOVERY_PENDING’

select *
from sys.databases

If you have a database backup and all the log files since that instant in time, you can restore your data.

Last resort: You can try open a database in EMERGENCY mode now (but your DB might be inconsistent because some of the transactions might be open):

ALTER DATABASE Northwind SET EMERGENCY

DBCC CHECKDB('Northwind') -- now (wrongly!) indicates no errors

Trick to loose your SQL SERVER log file. The two most important commands there:

SET DATABASE DemoSuspect SET EMERGENCY
GO
SET DATABASE DemoSuspect SET SINGLE_USER
GO
DBCC CHECKDB ('DemoSuspect', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;
GO
SET DATABASE DemoSuspect SET MULTI_USER
GO

Note that because of the repair, you lost ‘transactional consistency’!

Memory usage:

Page life expectancy should not fall below 300 seconds for a longer period of time.

When in doubt: Reboot!

Manually geneate a BSOD in order to be able to debug a hung system.
It can now also be done with USB keyboards in Windows Server 2003 SP2 and up, and Windows 7.
See also thishttp://support.microsoft.com/kb/972110.

Some more interesting links:

Encryption Hierarchy / Encryption Hierarchy

– Book: SQL Server 2005 Practical Troubleshooting (by the late Ken Henderson)

Security in SQL Server 2005

SQL Server 2005 Data Encryption and data length limitations

–jeroen

Posted in BASTA!, Conferences, Database Development, Development, Event, SQL Server | Leave a Comment »