Register WCF for IIS

I encountered problems when testing this code example on a newly installed server (Windows Server 2012 R2):

Consuming a WCF Service from an SSRS (RDL) Server Report

 

I got this error:

HTTP_Error_404.17

HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.

Most likely causes:
The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.

 

Relevant Windows features were already installed.

 

Resolved the problem by running this in a command prompt:

cd "C:\Windows\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation"

ServiceModelReg.exe –i

 

However this was not an ideal solution, because it broke newer sites with:

System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

 

Tried fixing it by running:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>  aspnet_regiis.exe -iru

 

Unfortunately that failed with:

This option is not supported on this version of the operating system.  Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog,  the Server Manager management tool, or the dism.exe command line tool.  For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.

 

Eventually I found the solution here: WCF on IIS8; *.svc handler mapping doesn’t work

 

Resolved the problem by running:

dism /Online /Disable-Feature /Featurename:IIS-ASPNET45

dism /Online /Enable-Feature /Featurename:IIS-ASPNET45 /all

dism /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation

dism /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation45

 

Also had to follow the advice from the Microsoft article:

Error message after you install the .NET Framework 4.0: “Could not load type ‘System.ServiceModel.Activation.HttpModule'”

By modifying the configuration file:

%windir%\system32\inetsrv\config\Applicationhost.config

With:

<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler,runtimeVersionv2.0" />

 

After this both the old (.NET 3.5) and newer (.NET 4.5+) sites were functional.

Enable ClearType on Windows 10

I noticed jagged text on a computer running Windows 10.

It was particularly noticeable with Firefox and Chrome.

 

I opened Advanced display settings and tried to open ClearType text.

ClearType_01_Display_Settings

 

However this failed with this error message:

ClearType_02_Windows_cannot_access_cttune

C:\Windows\system32\cttune.exe

Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.

 

Instead I tried to start cttune.exe directly:

ClearType_03_Run_cttune

 

This was possible and I noticed that ClearType was disabled (as expected).

ClearType_04_ClearType_disabled

 

I selected: Turn on ClearType

ClearType_05_ClearType_enabled

 

And completed the guide to adjust ClearType optimally.

ClearType_06_Adjusting_ClearType

 

That solved the problem. After enabling and adjusting ClearType, text in all programs looked much better without jagged edges.

Error when exporting Hyper-V virtual machine to USB memory stick

Recently I needed to export a Hyper-V virtual machine to another computer.

I decided to export it directly to a USB memory stick.

However it failed consistently with this error message:

An_error_occured_while_attempting_to_export_the_virtual_machine

An error occurred while attempting to export the virtual machine.

Failed to copy file during export.

Failed to copy file from 'C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\DeploymentTest5New4.vhdx' to 'E:\VM\DeploymentTest5\Virtual Hard Disks\DeploymentTest5New4.vhdx': One or more arguments are invalid (0x80070057).

 

I examined the file system on the USB stick and discovered that it was FAT32.

FAT32 has a file size limitation of 4 GB.

Most virtual machines are likely to be bigger than that and that was also the case here.

 

I decided to empty the USB stick and reformat it to NTFS.

Then the virtual machine could be exported without problems.

Windows Task Manager may prevent safe removal of USB drive

I recently experienced problems removing a USB drive safely from a Thinkpad T440p running Windows 10.

I saw this warning:

Windows_is_unable_to_stop_the_device

Windows is unable to stop the device 'USB Mass Storage Device'. Don’t remove this device while it is still in use. Close any programs using this device and then remove it.

 

I checked if I was deliberately using any files or folders on the drive, but that was not the case.

 

I checked which processes held handles on the D: drive using the useful utility handle.

C:\bin\Handle>handle d:\

Handle v4.0
Copyright (C) 1997-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

System             pid: 4      type: File           FA0: D:\$Extend\$RmMetadata\$TxfLog\$TxfLog.blf
System             pid: 4      type: File          1788: D:\$Extend\$RmMetadata\$TxfLog\$TxfLogContainer00000000000000000002
System             pid: 4      type: File          193C: D:\$Extend\$RmMetadata\$TxfLog\$TxfLogContainer00000000000000000001
System             pid: 4      type: File          1B60: D:\$Extend\$RmMetadata\$Txf

 

I found this in Event Viewer:

Log Name:      System
Source:        Microsoft-Windows-Kernel-PnP
Event ID:      225
Task Category: (223)
Level:         Warning
User:          SYSTEM
Description:
The application \Device\HarddiskVolume4\Windows\System32\Taskmgr.exe with process id 7432 stopped the removal or ejection for the device USB\VID_1058&PID_1023\57584C3145313145534A5A36.

 

The problem was solved by closing task manager. Then the USB drive could be removed safely.

AHCI power saving settings may cause system freezes

I experienced a frequent issue on a Lenovo Thinkpad T440p computer running Windows 10.

The system would sometimes become completely unresponsive for around 30 seconds, where every program would freeze.

Then the system would resume with very high disk activity for a while from the System and compressed memory process.

(Initially this made me suspect an issue with this process, but it seems like this was just a side effect)

 

In Event Viewer I found events like these around the time the freezes occured:

Log Name:      System
Source:        storahci
Event ID:      129
Description:
Reset to device, \Device\RaidPort0, was issued.

 

I found this blog post and discussion, which seems to have a solution and explanation:

Event ID 129 – storachi – Reset to device, DeviceRaidPort0, was issued.

 

The issue may be caused by AHCI power saving settings.

The simple workaround is to change the system power profile to High Performance under:

Control Panel -> Power Options

Power_Options_power_plan_High_performance

(This disables a number of power saving settings including one for AHCI)

 

Be aware that system freezes can also be caused by firmware bugs, driver bugs, defective SATA cable, failing harddisk/SSD and possibly other causes.

PowerShell: Check memory used by processes and virtual machines

PowerShell can be useful for many things.

There are PowerShell Cmdlets that make it fairly simple to examine the amount of memory used by processes or virtual machines.

 

Examples:

Sum of working set for all processes:

Get-Process | Measure-Object WorkingSet -Sum
"{0:N2} GB" -f ((Get-Process |
Measure-Object WorkingSet -Sum).sum / 1GB)

 

Sum of assigned memory for Hyper-V virtual machines:

Get-VM | Select-Object MemoryAssigned |
Measure-Object MemoryAssigned -Sum
"{0:N2} GB" -f ((Get-VM |
Select-Object MemoryAssigned |
Measure-Object MemoryAssigned -Sum).sum / 1GB)

 

Sorted list of processes with working set in megabytes:

Get-Process |
Select-Object Name,@{Name='WorkingSet';Expression={($_.WorkingSet / 1MB)}} |
Sort-Object -Property WorkingSet

Deployment error: Windows could not create a partition

I recently encountered problems when deploying Windows (using AutoUnattend.xml) on a test machine.

Installation failed with the message:

Windows_could_not_create_a_partition_on_disk_0

Windows could not create a partition on disk 0. The error occured while applying the unattend answer file’s <DiskConfiguration> setting. Error code: 0x80042565

 

I found these errors in: X:\Windows\Panther\setuperr.log

CreatePartition: Disk 0 doesn't support creation of partitions of the specified type
ApplyDiskOperationUsingService: Failed to correctly apply disk operation of type [0x7]; hr = 0x80042565
CallBack_DiskConfiguration_ApplyUnattend:An error occurred while applying unattend disk configuration; hr = 0x80042565

 

The situation occured because the computer booted in BIOS mode, while the DiskConfiguration specified in AutoUnattend.xml was for UEFI.

(I suspect that similar problems will occur in the opposite situation)

When actively choosing UEFI in the boot menu, it worked as expected.

 

In Windows PE the firmware type can examined by checking the registry key:

HKLM\System\CurrentControlSet\Control\PEFirmwareType

 

If booting in a particular mode is desired, the deployment media can be modified to achieve this:

  • UEFI, not BIOS: Remove bootmgr file from media root.
  • BIOS, not UEFI: Remove efi folder from media root.

 

Discovered the details about identifying firmware type and enforcing booting from a particular firmware type in the article: WinPE: Boot in UEFI or legacy BIOS mode

Alt Gr key not working normally

If you use a Lenovo Thinkpad computer running Windows 10 you may experience a situation where the Alt Gr key stops working normally and just works as the regular Alt key.

Ctrl + Alt can be used as a substitute, but that’s only a workaround.

The problem seems to be related to the Synaptics Pointing Device driver.

 

The problem can be resolved for some time by reinstalling, rolling back or updating the Synaptics Pointing Device driver and then restarting the computer.

The problem can reappear after some weeks. However it can be resolved again by repeating the above steps.

If I discover a permanent fix, I will update the article again.

 

The driver can be rolled back this way:

1. Open Device Manager

2. Open Properties for Synaptics Pointing Device

Synaptics_Pointing_Device_01

3. Click: Rollback driver

Synaptics_Pointing_Device_02_Roll_Back_Driver

4. Restart the computer.