tags:

views:

23

answers:

2

I have code like this which runs fine on windows 7...

TimeZoneInfo _timeZoneInfo = TimeZoneInfo.Local;

It doesn't work on XP SP3. The error given is...

A first chance exception of type 'System.EntryPointNotFoundException' occurred in System.Core.dll

Additional information: Unable to find an entry point named 'GetDynamicTimeZoneInformation' in DLL 'kernel32.dll'.

Looking at the help for the function GetDynamicTimeZoneInformation I see that it's only available on vista+

Any ideas?

+1  A: 

If its not in XP, then you're not going to be able to use it, and sadly it's not just a case of copying a DLL over from a different box.

Can you use this method of getting the TimeZone ? MSDN says its supported in XPSP3 and higher:

TimeZone localZone = TimeZone.CurrentTimeZone;
Russ C
Ok thanks, I'll try the older timezone class and see how it goes.
I've added a new answer to follow up to this since the text was too long for this box...
A: 

I've changed the code and that'll work ok. Thanks. Problem now is that I used to have a TimeZoneInfo memeber in a DataContract. I had to add KnownType attibutes to get the DataContract and the TImeZoneInfo classes to work properly. I suspect I need to add similar KnownType attibutes for the TimeZone class since I am getting the following error:

Additional information: There was an error while trying to serialize parameter http://VisualSoft/NetworkService/Library:tInfo. The InnerException message was 'Type 'System.CurrentSystemTimeZone' with data contract name 'CurrentSystemTimeZone:http://schemas.datacontract.org/2004/07/System' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.

Does anyone know the correct way of getting the old TimeZone class to work in a datacontract? I tried the obvious [ServiceKnownType(typeof(System.TimeZone))] and [KnownType(typeof(System.TimeZone))]

You'll need to post this as a new question, as you've accepted my answer, it wont flag up as un-answered in the list.
Russ C