Why WPF and not WinForms

Jul 19
2015

Since I had to repeat often why I choose WPF for .NET programming over WinForms, I have decided to write down my reasons here:

    WPF works much better than WinForms on todays high-resolution monitors like FullHD tablets and 4K displays
    with WPF it is much easier to build the moden interface designs my customers are asking
    WPF has a very powerful binding and is made for modern programming paradigms like MVVM. Therefore it permits a much cleaner design of the program structure
    WPF is what Microsoft recommends for new applications

I think, these reasons are worth to discard what I know about the Windows API.

Windows Service and WinINet

May 20
2015

Today unfortunately I have discovered that WinINet calls don’t work in a service.

I need to put a file with FTP somewhere and call than a URL with http to update the data.

Microsoft says that instead of WinINet in a service the WinHTTP functions should be used. Unfortunately, WinHTTP has no support for FTP, so you need to use a 3rd party library in a Win32 service. (I used FCE from Marshallsoft).
And then: the WinHTTP interface is much more complicated to call than WinINET, and after working for a while on the WinHTTP interface (unfortunately it is not implemented in Visual Objects) I decided to use an external call to cURL.

The “VO-way” of programming does not work with WPF

Nov 21
2014

Today unfortunately I discovered that the “VO-way” of developing Windows applications does not work with WPF.

In VO, we used to paint a window in a separate application module, and to not write any code in this generated class. The hand written code was placed instead in a separate module, and in a subclass of the generated window. This separated first written code from generated one, and secondly it was easier to manage.

Unfortunately, WPF does not support such a (IMHO clean) style of programming, as XAML windows cannot be inherited.

I have found a document on MSDN on this subject:

MSDN:make a custom windows inherit from window

and it seems the way of using UserControls is the only remaining possibility to reuse paintend windows.

WPF applications with VIDE

Nov 21
2014

Since I like VIDE more than Visual Studio, I would continue to use it also on WPF programming with Vulcan.NET.

Unfortunately, VIDE does not support XAML, since it has no XAML editor integrated, and it does not compiles XAML to BAML. At the moment, Chris Pyrgas, the author of VIDE, is searching ways to integrate both a XAML editor and the compiling of XAML to BAML into VIDE.

But fortunately there are methods to accomplish this now. At this moment, I know 3 of them that work, the 4th that would be my favorite one, unfortunatley does not work:

1) don’t use XAML and construct all windows in plain Vulcan code. It gives more flexibility creating the windows, but it seems it willbe more work.
2) create the windows in Visual Studio or Blend, creating C# code. All the other code used for MVVM can be written in Vulcan.NET using VIDE. This was discovered and tested by Frank Maraite who will be able to give also samples.
3) Chris Pyrgas has showed another method: create the windows in Visual Studio as Vulcan.NET projects. Then add the code-behind files as source code files to the VIDE project, and also the VS-compiled resource files as external resources. A sample for this can be requested.
4) this (unfortunately not working) method is called by me “The VO way”, as it uses concepts from Visual Objects. The windows are created in Visual Studio, maybe as based on classes created in VIDE, and compiled to a DLL. Without writing any code, the application itself is written in VIDE, with the VS generated DLL as dependency, and the used windows are inherited from the ones written in Visual Studio. Unfortunately, this method does not work, as the WPF does not support inheriting from a XAML window.

552 5.3.4 Message size exceeds fixed maximum message size – SBS 2011

Nov 06
2014

Recently, I had problems with an SBS 2011 Server where the Exchange 2010 does not accepted mails with more than 10 MB (the default limit), and fetchmail returned an

552 5.3.4 Message size exceeds fixed maximum message size

error.
I have changed the limit everywhere (Organisation and Server properties), but not on the Windows SBS 2011 Fax Sharepoint connector, but it does not worked until I changed this also on the SBS 2011 Fax Sharepoint connector.

Windows 8.1 – Errors on modern apps

Oct 02
2014

When installing Windows 8.1 without a Microsoft account, and also when integrating the PC in a Windows domain, very often the apps on the app screen show up with a “X” in the angle, or with “error” after their name.

It seems there is going something wrong in this configuration, as I saw this very often (my customers are all professional users, no home users).

I have found now a solution to this:

http://answers.microsoft.com/en-us/windows/forum/windows8_1-windows_store/all-modern-apps-fail-to-start-after-windows-81/a80793c7-c214-43ec-9ca9-5c758f9ad840?page=2

In short, the solution is the following:

– the owner of the key

HKEY_CURRENT_USER\Software\Classes\Local Settings\software\microsoft\windows\currentversion\appmodel\repository\packages

needs to be changed to SYSTEM (using the advanced button in RegEdit
– execute the following on an administrative command prompt

Powershell -ExecutionPolicy Unrestricted Add-AppxPackage -DisableDevelopmentMode -Register $Env:SystemRoot\WinStore\AppxManifest.xml

to fix the Store app
– execute a Powershell with administrative rights and execute this command:

((Get-ChildItem “HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\InboxApplications”) | Get-ItemProperty).Path | Add-AppxPackage -Register -DisableDevelopmentMode

This was enough – no reboot needed, the store app loaded and also the single other apps.

SHDSL configuration – Italy – Cisco 1841

Oct 02
2014

SHDSL seems a dead tecnology, as it can transfer only 2 MB per cable pair, so if you wish to have 4 MB, you need 2 cable pairs.
Unfortunately here in Italy in some places it is not possible to have more than 640k ADSL, with 64 upstream, so SHDSL Liberty 2 MB seems the only choice for several customers.

Telecom Italia gives a (obbligatory) modem with a V35 to the customer, and would like to rent also a Cisco router – with prices of more than 100 Euro a month. Since SHDSL is a dead tecnology, it should be absolutely no problem to find a used Cisco 1841 router on eBay, for prices of a few 100 Euro. You need also a serial interface in this router (WIC2t interface for 2 serial interfaces) and a cable with a V35 interface on the one side and a serial interface on the other (it is not a classic serial interface with a 9 or 25 pin like on PCs!).
And if you acquire the router, pay attention to receive also the console cable (RJ45 on one side to connect to the router, serial 9 pin on the other side to connect to your PC).

The Cisco router has only a command line interface, and for me worked this configuration (IP addresses and passwords masked):

Using 1190 out of 196600 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname cisco1841
!
boot-start-marker
boot-end-marker
!
enable secret 5 ?????
enable password ?????
!
no aaa new-model
!
resource policy
!
mmi polling-interval 60
no mmi auto-configure
no mmi pvc
mmi snmp-timeout 180
ip subnet-zero
ip cef
!
no ip dhcp use vrf connected
!
no ftp-server write-enable
!
interface FastEthernet0/0
ip address a.b.c.d 255.255.255.248
speed auto
half-duplex
no mop enabled
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
interface Serial0/0/0
bandwidth 2048
no ip address
encapsulation frame-relay IETF
no fair-queue
!
interface Serial0/0/0.1 point-to-point
bandwidth 2048
ip address e.f.g.h 255.255.255.252
frame-relay interface-dlci 577 IETF
!
interface Serial0/0/1
no ip address
shutdown
clockrate 2000000
!
ip classless
ip route 0.0.0.0 0.0.0.0 Serial0/0/0.1
!
ip http server
no ip http secure-server
!
control-plane
!
line con 0
line aux 0
line vty 0 4
password ?????
login
!
end

a.b.c.d is the address of “default gateway” on the configuration sheet (the second address of the assigned range), and e.f.g.h is the address of point-to-point (Punto Punto on the configuration sheet).

You can find a conversation about this here:

http://www.ciscoforums.it/viewtopic.php?f=10&t=30638

Windows 8 and Autodesk products, Installer issue

May 06
2014

On several Windows 8 machines there was a problem with Windows Installer that tried to execute the setup of AutoCad LT 2013 or DWG TrueView 2015.

Unfortunately, I could not find anything usable using my best troubleshooting friend: Google.

The solution for DWG TrueView

The solution came from looking in the event viewer under the Windows item, Applications. There was a error message like this one:

“Erkennung von Produkt “{5783F2D7-E028-0409-0100-0060B0CE6BBA}”, Feature “P” und Komponente “{370E1EB0-04EF-4807-8B56-4562457473B8}” fehlgeschlagen. Die Ressource “C:\Users\Lukas\AppData\Roaming\Autodesk\WebServices\Dummy.txt” ist nicht vorhanden.”

But the user “Lukas” was the one that installed DWG TrueView on this machine, and other users had not access to this file. The solution was simple: create a file “dummy.txt” in a directory accessibile to all users (I opted for “C:\ProgramData\Autodesk\Dummy.txt”, search the reference in the registry (was the entry “7D2F3875820E9040100000060BECB6AB” in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\0BE1E073FE407084B86554265447378B) and change the file location.

The solution for AutoCAD unfortunately was not so fast: in the eventviewer I could see that the installer tried to access a registry entry, precisely this one:

HKEY_CLASSES_ROOT(64)\TypeLib\{76B039F4-D977-4B80-8DEB-DCD74D6B337F}\1.0\0\win64\

Using RegEdit, I could not read that entry because it was not accessible. So I needed to change first the owner of the respective registry tree to “Administrators” and then add the right to read for all users – unfortunately several steps because this was to repeat for 3 different items, and the subitems became only visible after adjusting the properties of the owner item.

Addendum: DWG TrueView 2014 had the same issue as AutoCAD 2013.

It seems that the guys at AutoDesk have to adjust their installers….

Fastest route from fresh installed Windows 8 to Windows 8.1

Apr 18
2014

These days, I had to upgrade several XP PCs to Windows 8.1, and since I had several W8 upgrade licences in my office, and since the migwiz tool on Windows 8.1 does not accept data from XP, I had to go through Windows 8.
Unfortunately, a fresh installed Windows 8 does not let you install Windows 8.1 upgrade from the store, you have to install first several Windows updates.
Fortunately, I found that the needed updates are only two, both near to the bottom of the update list.
KB2871389
KB2917499
So you can let search fpr updates, deselect all important updates clicking on the top checkbox near to “Name”, scroll down to thhe bottom of the list and select only these two updates. Let complete the update and reboot. Then enter the store and you can install Windows 8.1 from there.

P.S. there is a nice thing: the fresh installed Windows 8.1 has the recently published update to Windows 8.1 already integrated, so you save a lot of updates.

Detecting paste operation in Richtext control

Apr 09
2014

Today, I had the need to intercept the paste of text in a RTF control to remove some formattings (font type and size).

Unfortunately the Richtext control is a special beast, and this is not possible before Windows 8.

On Windows 8, EN_CLIPFORMAT message is sent to the owner window, but unfortunately at this moment there is no way to do this on versions before (I need Windows 7 support). More informations you can find on stackoverflow.com:

http://stackoverflow.com/questions/5618162/detecting-if-paste-event-occurred-inside-a-rich-text-box

My (not perfect) solution consists in a extra context menu on the control that calls my own Paste method.