Windows Embedded Compact 2013 Local Date and Time Error

Mark Williams 6 Reputation points
2022-06-17T15:09:50.183+00:00

Hi all, we are migrating a platform from WEC7 to WEC2013 (I know late in the day) but have immediately hit a problem in our .NET application calling DateTime.Now. This throws a null reference exception. DateTime.UtcNow works ok so some issue translating to local time.

After a bit of debugging it would seem that GetTimeZoneInformation is returning TIME_ZONE_ID_INVALID which then seems to trip something up in the .NET code. If I force the response to another value then the call continues without issue. Interestingly TIME_ZONE_ID_INVALID is not in the API docs but is a response from this function.

https://learn.microsoft.com/en-us/previous-versions/windows/embedded/ee488172(v=winembedded.80)

I am now trying to work out what is wrong/missing with our WEC2013 OS image. I can see that the timezone uses the default which is GMT and loads that timezone info structure. But GetTimeZoneInfo then seems to fail comparisons with UserKInfo[KINX_TIMEZONEBIAS] and I cannot see where this value is set up to debug further.

Could anyone help shed any light on this? What are we missing that needs to be set up for the .NETCF to work out local time?

Thanks in advance, Mark

Windows for IoT
Windows for IoT
A family of Microsoft operating systems designed for use in Internet of Things (IoT) devices.
105 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michel Verhagen 96 Reputation points
    2022-10-19T07:57:10.737+00:00

    Hi, this is a bug in Compact 2013 that only appears if you don't use the hive based registry. I'm guessing your device uses the RAM based registry?

    If so, add this to your registry and all will work fine:

    ;------------------------------------------------------------------------------  
    ; Make sure time-zone functionality works:  
    ;   NKSetTimeZoneBias fails if reg key [HKLM\init\Bootvars] is not present and  
    ;   this key is normally only created when hive-based registry is selected in  
    ;   the OS catalog.  
    ;------------------------------------------------------------------------------  
    IF SYSGEN_FSREGRAM  
    [HKEY_LOCAL_MACHINE\init\Bootvars]  
    ENDIF  
    
    No comments