Thursday, 12 February 2015

Changing password in RDS-in-RDS session

It was already a common knowledge for me that for starting password changing dialog in a remote session CTRL+ALT+End shortcut should be used instead of CTRL+ALT+DEL. Simply because the latter always opens the dialog on the outer computer.

There is a Registry change that forces almost all shortcuts to be handled by a remote session. In the following key set the value for "TransparentKeyPassthrough" to "Remote". Unfortunately it does not work for CTRL+ALT+DEL.

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\ICA Client\Engine\Lockdown Profiles\All Regions\Lockdown\Virtual Channels\Keyboard

A solution is to start the on-screen keyboard (OSK.EXE), press CTRL+ALT on the physical keyboard, and then press DEL on the on-screen keyboard. This places the shortcut exactly where it should be placed -- in a session that hosts the instance of the on-screen keyboard.

This trick works even if you are in a remote session launched from a remote session.

After sharing this information with colleagues, I was stunned to find -- LOL -- "Windows Security" item in the Start Menu. As they say: these things happen.


Monday, 2 February 2015

Cannot add a SimpleContent column to a table containing element columns or nested relation

This is a classic case of an error message that is not exactly a misleading one, but one that must be interpreted properly.

This is the story. In a WCF application, I added a dataset based on T-SQL query. Everything worked as expected. In my tests, I was able to fill a dataset, and send it back to WCF client. The dataset was a public member of a class instance.

My next step was moving the actual query to a stored procedure. The purpose was to keep consistent design across the WCF application. All dataset in the app were designed to call respective stored procedures, rather than execute direct SQL SELECT statements.

This is were my WCF client started to throw an exception: Cannot add a SimpleContent column to a table containing element columns or nested relation.

I admit giving only a little effort understanding the error message. And yes, I googled the text of the error message, a lazy approach. Then I tried to change the stored procedure first to an inline function, and then to a multi-statement function. As you understand, the outcome was exactly the same.

The actual System.Data.SqlClient.SqlException error, and I had to caught it on WCF server side, was caused by missing SELECT permission on SQL Server function I created. So there was no valid dataset returned with WCF server's responses, which subsequently was causing deserialization fail on WCF client side. Simple!


Monday, 26 January 2015

Access to ClickOnce application directory

A ClickOnce application, through GUI, impersonates a user to query a database. For some reason this impersonated user does not have access to EntityFramework.dll in the application directory.

************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied.

File name: 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I wasted absolutely unreasonable time looking in a wrong direction: EntityFramework version conflicting with .NET Framework version and so on. While a solution was on the surface: the impersonated user to be given Read & Execute access to the application directory.


Sunday, 28 September 2014

Currency field type in VFP9

VFP9 stores currency data as Int64 (8 bytes). The original value is multiplied by 10,000, then rounded to 0 decimal places, and then stored in a table. For example, 12.4301 is stored as 124301.

Currency field type has 4 fixed decimal places.

Normally this knowledge is irrelevant because the VFP converts numbers to currency and backwards implicitly. Only if you need to access tables on a lower level, you need to know this.

Friday, 26 September 2014

WPF DataGridColumnHeader cuts off first underscore character

In my WPF project I populate a data grid from a random source (a table in a database), so the number of columns and the column names vary each time the grid is filled. The column names of a table are used as grid headers. During testing I found that every grid header with underscore characters always has the 1st one cut off. The reason is that WPF uses the underscore character for marking accelerator keys.

If left as is, it will certainly confuse a small number of end-users. The majority of course will not notice, which still cannot excuse the developer from fixing the issue. Declaring it a feature in user manual is even more laughable because nobody ever reads user manuals except for searching a phone number to call and swear at support.

So I need a solution. First I decided to choose a complex path. No, first of course I started to Google. And then the second step, I decided to try either an event handler or to start messing up with DataGridColumnHeader's style and template. The results were as ugly as unsatisfactory.

But then, bingo, came a solution. If this guy, the DataGridColumnHeader, likes to have underscores for breakfast then make sure it has one every time. So now I simply prefix headers with the underscore. The issue is resolved.


FixieBreaky: when purging database records keep the transaction log in mind

The space on a database server was shrinking. That was not a danger level yet, though the trend left no mistakes: in about two month it would be over. A colleague of mine decided to delete a large amount of obsolete records in a database on the server.

Neither he nor anybody else around did not give a second thought about the transaction log growth caused by the deletions. That included me, even though I stepped into same trap a year ago.

Lessons:
Database backup is extremely important.
Heroic actions is not a substitute for planning.
No matter how large and expensive a storage is, one day it'll be filled
No magic software tool is a substitute for planning
Stay alert, whatever comes to you, look into your previous experience
Blaming and punishing is not a substitute for planning