Delegates sample

Feb 21
2016

Hi,

when working with X# and Vulcan.NET, I have created this particular sample. It should help understand how delegates work (and that they are immutable):

#using DelegateSample

begin namespace DelegateSample

public delegate SampleDelegate( cParameter as string ) as void

function Start( ) as void
  local oSample as SampleClass
  local oSample2 as Sample2Class
  local oDelegate as SampleDelegate
  local oDelegate2 as SampleDelegate

  System.Console.WriteLine(“Start SampleDelegate”)

  oSample := SampleClass{}
  oSample2 := Sample2Class{}

  oDelegate := SampleDelegate{ oSample:Method1 }
  oDelegate += oSample:Method2
  oDelegate += oSample2:Method3

  oDelegate( “Hi” )
  oDelegate2 := oDelegate

  oDelegate -= oSample:Method2
  oDelegate -= oSample2:Method3

  oDelegate( “Hott” )
  oDelegate2( “Hups” )

  return

class SampleClass

  constructor()

  return

  public method Method1( cParameter as string ) as void

    System.Console.WriteLine( “method1, parameter ” + cParameter )

    return

  public method Method2( cParameter as string ) as void

    System.Console.WriteLine( “method2, parameter ” + cParameter )

    return

end class

class Sample2Class

  public method Method3( cParameter as string ) as void

    System.Console.WriteLine( “method3, Sample2Class, parameter ” + cParameter )

    return

end class

end namespace

Windows 10 Start menu missing, apps not working

Nov 10
2015

Today, I had a severe problem on a users Windows 10 Tablet (Dell Venue Pro 11).

This machine suddently stopped showing the start menu, and no app worked. Even the Notify screen was unable to start.

I have tried a lot of things, until I looked in the Event Viewer (Applications), and there I found a lot of errors like this one:

svchost (2356) TILEREPOSITORYS-1-5-21-1151363738-2262017715-1772219638-1001: Non è stato possibile leggere l’intervallo di log dal file “C:\Users\Michele\AppData\Local\TileDataLayer\Database\EDB.log” all’offset 1056768 (0x0000000000102000) per 4096 (0x00001000) byte a causa di una mancata corrispondenza del checksum dell’intervallo. Checksum previsto: 3595365752422194926 (0x31e54e1a4ebadeee). Checksum effettivo: 3595365752422194926 (0x31e54e1a4ebadeee). L’operazione di lettura non verrà effettuata con errore -501 (0xfffffe0b). Se tale condizione persiste, ripristinare il file di log da un backup precedente.

To solve, I have opened a Administrator command prompt, moved to the indicated folder and renamed all .log files to .loa.

After this, the start menu and the apps worked again.

Opening PDF files from network folder with Adobe Reader DC

Nov 03
2015

In some of my software programs, I have integrated a thing like document archiving, and there customers are putting several files, mostly PDF.

Since Adobe Reader is out and installed on the machines, often PDF files that are on a shared network folder, cannot be opened anymore – Adobe Reader gives an “access denied” error.

It is the “Protected Mode” of Adobe Reader that gives this problem.

Fortunately you can disable this mode, and Adobe Reader works again as expected. Please don’t forget to enable the protected mode afterwards!

This is my VO code for this functionality:

// disable Adobe Reader protected mode
aVersions := { “11.0”, “DC” }
aReset := {}
nLen := ALen( aVersions )
for nI := 1 upto nLen
 cVersion := aVersions[nI]
 nMode := RegistryDWord( HKEY_CURRENT_USER, “Software\Adobe\Acrobat Reader\” + cVersion + “\Privileged”, “bProtectedMode” )
 if nMode == 1
  SetRegistryDWord( HKEY_CURRENT_USER, “Software\Adobe\Acrobat Reader\” + cVersion + “\Privileged”, “bProtectedMode”, 0 )
  AAdd( aReset, cVersion )
 endif
next
oProcess := SpawnProcess{ cExe, cFileName, SW_NORMAL }
for nI := 1 upto 20
 ApplicationExec( EXECWHILEEVENT )
 Sleep( 500 ) // let Acrobat reader start
next
// re-enable Adobe Reader protected mode
nLen := ALen( aReset )
for nI := 1 upto nLen
 cVersion := aReset[nI]
 nMode := RegistryDWord( HKEY_CURRENT_USER, “Software\Adobe\Acrobat Reader\” + cVersion + “\Privileged”, “bProtectedMode” )
 if nMode == 0
  SetRegistryDWord( HKEY_CURRENT_USER, “Software\Adobe\Acrobat Reader\” + cVersion + “\Privileged”, “bProtectedMode”, 1 )
  AAdd( aReset, cVersion )
 endif
next

Escaping double quotes in Vulcan.NET

Oct 25
2015

Trying to optimize building SQL insert and update strings, the following VO code:

cTable + ‘”‘ + cFieldName + ‘”‘

in Vulcan.NET works as follows

cTable + “.” + chr( 34 ) + cFieldName + chr( 34 )

But of course is not very performant. Better is the following code:

string.Format( e”{0}.\”{1}\””, cTable, aValues[nI,1] )

Please note the “e” character before the string – it enables escaping the double quotes with the backslash.

The entire method for building an append statement ist the following:

static method CreateInsertString( cTable as string, oFieldValues as List<BaseField> ) as string
 local oField as BaseField
 local oStatement as StringBuilder
 local oValues as StringBuilder
 local cStatement as string
 local cValues as string
 local nLen as int
 local nI as int
 local cField as string
 local uValue as usual
 local cValue as string

 cStatement := string.Format( “insert into {0} ( “, cTable )
 oStatement := StringBuilder{ cStatement, 512 }
 oStatement:Append( ” values ( ” )
 oValues := StringBuilder{ 512 }
 nLen := oFieldValues:Count – 1
  for nI := 0 upto nLen
  oField := oFieldValues:Item[nI]
  cValue := FirebirdHelper.ConvertValueToStatement( oField:Value )
  if nI < nLen
   oStatement:AppendFormat( “{0}, “, oField:Name )
   oValues:AppendFormat( “{0}, “, cValue )
  else
   oStatement:AppendFormat( “{0}) “, oField:Name )
   oValues:AppendFormat( “{0}) “, cValue )
  endif
 next
 oStatement:Append( oValues )
 cStatement := oStatement:ToString()

 return cStatement

Firebird syntax differences to other SQL databases

Sep 30
2015

Insert statements

Until now, I have used insert statements in the form

insert into mytable field1 = 1, field2 = ‘hello world’

Firebird does not like this, it needs the form

insert into mytable ( field1, field2 ) values ( 1, ‘hello world’ )

Masking apostrophes
Also Firebird does not likes masking apostrophes with the backslash

‘Hello, I\’m Wolfgang’

but needs two apostrophes

‘Hello, I”m Wolfgang’

Autoincrement fields
Firebird unfortunately does not have autoincrement fields as MS SQL or MySQL, but needs a trigger and a generator (other databases call it sequence), as it needs also the Oracle database.

Database managment tools
Until now, used DBTools Manager Professional or Navicat Premium Essentials to manage my SQL databases. Unfortunately, DBTools Manager does not work very well with Firebird, and Navicat has no Firebird support. The FlameRobin is very “basic” and has also some problems working with it, so after searching for a low-cost and good-working alternative I have decided for IBExpert Desktop.

Firebird installation on Debian server

Sep 11
2015

Installing Firebird on Debian (Jessie in my case) gave a problem: after installing and starting the server I was not able to connect to the database server:

Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

using the sysdba password I entered in the installation dialog.

Unfortunately it seems the installation procedure has a bug, and does not accept the entered password, but attributes a random password. This random password can you find in the file

/etc/firebird/2.5/SYSDBA.password

The connect with this random password succeedes and you can change your password afterwards – but you must change it with both the Firebird administration tools and inside this file.

The password can be changed with the gsec tool:

gsec -user sysdba -password <password_from_SYSDBA.password>
modify sysdba -pw <your_new_password>
quit

And another speciality for Debian:

The isql tool is called isql-fb

Windows 10 do not likes the netlogon share on server (Samba or Windows)

Aug 28
2015

Today, I had an interesting issue: Windows 10 (workgroup setting, local account) does not connect to the Samba netlogon share, even with the latest Samba version (4.2.3), it asks username and password.
Access to other shares works without any issue.
I had also checked the HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuest setting – it does not change anything.
My temporary solution was to create a new share, identical to the netlogon share, with another name – I choosed netlogonw10. Calling the login script from this share works.

The same is true also for netlogon shares on Windows servers, if the machine is not in the Windows domain

Windows 10 Upgrade experiences

Aug 17
2015

On this page, I will give Windows 10 Upgrade experiences, from our company PCs and from the PCs of customers.

First of all, the Windows 10 upgrades seem to work very well, specially when coming from Windows 8.1. I have upgraded several of our own machines (Fujitsu Stylistic Q703, Acer Iconia Tab W700, Fujitsu Esprimo X923T, an old Fujitsu Lifebook C1410, Acer Veriton N4620G with an i3-2377 all from Windows 8.1, without any problem).
I have also not encountered any problems on my former development notebook, a Fujitsu Lifebook E8410 with Nvidia Graphics, upgraded from Windows 7 Pro.
I have also upgraded several custom machines successfully, most of the Fujitsu brand.

Unfortunately, I was not able to upgrade my current development machine, a Fujitsu Celsius H720. I have tried it two times, both times the upgrade from Windows 7 Pro failed with the message “Die für das System reservierte Partition konnte nicht aktualisiert werden” – traduced to “The reserved partition for the system could not be upgraded”. So I need to reinstall this machine from scratch.

One of my customers had an issue with a Dell Venue Pro 10″ with Windows 8.1 Pro: the machine hung in the reboot process for nearly an hour, and after a reboot the machine was returned to Windows 8.1. Addendum: I have cleaned up the HDD and installed Windows 10 successfully from an USB stick.

Another machine, a Fujitsu Esprimo P510, after the upgrade had lost the connection to the network – no IP address could be retrieved and also a static IP don’t helped. I downloaded the correct driver from Intels homepage, installed it, and the machine returned to work. It had an Intel I217-V chip.

A Acer Veriton with Intel Atom (D510) could not be upgraded – it hung in the reboot phase, and restored after than. I have tried the upgrade 3 times, without luck.

And a link for everyone interested in the upgrade: if you have more than one machine, build an USB stick for the upgrade with the Media Creation Tool:
https://www.microsoft.com/de-de/software-download/windows10

antiabzockenet.blogspot.com

Aug 08
2015

This one is not a tecnical issue, but something I would like to share.

Yesterday, I have received a very amusing email (unfortunately, it is in German, and translating it to English would loose the amusing elements):

Guten Tag,

seit vielen Jahren biete ich News, Infos und Verbraucherinformationen auf meinem Blog an.
In letzter Zeit fehlt mir jedoch das Geld, um mich meiner Mission in angemessenem Umfang widtmen zu können.
Da ich jedoch denke, dass meine Mission für jeden meiner Mitmenschen von großer Wichtigkeit ist, geht Ihnen Ihnen hiermit eine

++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bestellbestätigung zur monatlichen Zahlung von 19,90 ?
++++++++++++++++++++++++++++++++++++++++++++++++++++++

für die nächsten 12 Monate zu. Sollten Sie mit der Zahlung NICHT einverstanden sein, dann

widersprechen Sie diesem rechtsgültigen Vertrag durch Ausfüllen des Kontaktformulares auf meinem Blog http://antiabzockenet.blogspot.de/
Widersprüchen per E-Mail wird NICHT (!) stattgegeben, es wird in diesem Fall nach 7 Tagen eine rechtsgültige Mahnung per Post folgen!

Nachfolgend Ihre Bestell-Details:

Rechnungsanschrift:
info@riedmann.it

Rechnungsnummer: 31016627
Datum: 05..08.2015
IP-Adresse: 79.207.86.46

Artikelnr. Stück Artikeltext Unit Price Total EURO
___________________________________________________________________________________________
——————————————————————————————-
1001 1 Unterstützung antiabzockenet.blogspot.de 19,90 EUR 19,90 EUR
Vertragslaufzeit 12 Monate bis 09/2016
——————————————————————————————–
Summe der Artikel: 238,80 EUR
Versandkosten: 0,00 EUR
Gesamtsumme: 238,80 EUR

Diese Leistung ist umsatzsteuerfrei gemäß §19 (1) Umsatzsteuergesetz

Bitte überweisen Sie den Rechnungsbetrag innerhalb von 7 Tagen nach Erhalt dieser Rechnung entweder per Paypal oder Google Wallet an folgende E-Mail-Adresse:
o.forseti@hotmail.com

Bankdaten erhalten Sie auf Nachfrage per E-Mail.

Verwendungszweck: Unterstützung antiabzockenet.blogspot.de

Nach Bezahlung erhalten Sie noch eine ordentliche Abschlussrechnung Mit freundlichen Grüßen O.Forseti

Sie erhalten diese E-Mail aufgrund einer rechtsgültigen Bestellung auf http://antiabzockenet.blogspot.de
Impressum: O. Forseti, Bürgerheimstr. 23, 10365 Berlin
Telefon: (030) 47475582 , Telefax: (030) 47475583
E-Mail: o.forseti@hotmail.com

(in short: there is someone sending an invoice for supporting his blog for 12 months, asking 19,90 Euro for every month, and requesting the payment in 7 days with PayPal od Google Wallet.)
The entire email is full with syntax errors, gives as invoice address only the email address to which the invoice is sent, and indicates an IP address originating the order that cannot be mine, as I’m based in Italy and the indicated address is from Germany:

Origin of 79.207.86.46

I’m very curios, if the author of this very obscure invoice will re-contact me, as I plan to answer such an email.

MVVM and WPF – Literature

Jul 30
2015

Unfortunately there are no good books about the use of WPF and MVVM in Windows applications, and only a few good articles about it.

So I have decided to make here a list of web ressources that helped me to understand how WPF and MVVM works.

A good basic article is this one here, by Shamlia from Microsoft:

Understanding the basics of MVVM design pattern

Another recommendend reading is the introduction to MVVM by Paul Grenyer:

An Introduction to the WPF with the MVVM – Part 1

or maybe the link to the entire PDF document:

An Introduction to the WPF with the MVVM – PDF

Another recommended reading is the excellent EBook by Josh Smith – Advanced MVVM (available on Amazon and Lulu, and AFAIK also as paperback). It is worth the few money it costs:

Josh Smith – Advanced MVVM

And as last: Josh Smith wrote also a series of introductory articles to WPF on CodeProject:

Josh Smith: A guided tour to WPF

Other than, please look at Josh Smiths MVVM Foundation project – it is a very essential sample for a MVVM framework containing only a few basic classes:

Josh Smith: MVVM Foundation project

On StackOverflow, someone recommended me the following article by Jeremy Likness:

Jeremy Likness: Model-View-ViewModel MVVM Explained

Another guy writing a few articles about the structure of MVVM applications is Rico Suter, start with this one:

Rico Suter: Recommendations and best practices implementing MVVM WPF applications

And as last, articles in German language are available on the page of Norbert Eder, an Austrian programmer and author. Start here:

Norbert Eder: MVVM – das ViewModel

If someone has another recommended reading, please drop me an email at wolfgang@riedmann.it – I will check it and eventually add it here.