12/21/2010

GetUserAvailability Throws InvalidTimeIntervalException

I followed the examples by MS regarding Exchange Web Services and initially the program worked fine. Then, the next morning it trew a InvalidTimeIntervalException!

I hadn’t changed a thing!

After some trial and error I found the culprit: the time portion of the TimeWindow passed to GetUserAvalability is completely ignored! So for the service the TimeWindow had a length of zero, as the start and end dates were the same. The reason why it had worked the day before was that the 8 hours I had added to the start time resulted in the next day during the afternoon :-)

So always make sure to work with full days here, and also expect full day results to be retuned – you always work in 24-hour-chunks starting at 0:00 hrs.

There is no documentation on this yet, but at least I found a statement from MS that supports my findings here.

12/20/2010

Android APN Einstellungen für Maxxim friends4free

This post is in German as it will apply to German users only.

Die folgenden Einstellungen funktionieren bei mir bestens, sowohl für Internet wir auch MMS:

Name: frei wählbar

APN: internet.telco

Proxy: leer

Port: leer

Nutzername: leer

Passwort: leer

Server: leer

MMSC: http://10.81.0.7:8002

MMS-Proxy: 82.113.100.38

MMS-Port: 8080

MCC: 262

MNC: 07

APN-Typ: leer

Um die MMS-Nutzung zu aktivieren (vor dem Empfang der ersten MMS), muß man evtl. selbst erst eine verschicken!

Ich hoffe, das bewahrt jemanden davor, so lange suchen zu müssen wie ich :-)

Thunderbird and Hotmail (Live Mail)

My Hotmail email account was recently hacked, so I changed the password. Of course, you want a strong, long password, so I had KeePass generate one for me.

Well, it turned out that this was the source of the problem I got after changing my password: Thunderbird was not able to authenticate with Hotmail any longer.

I tried to use less and then no special characters at all, to no avail. Finally, I changed the length of my password to 10, it had been 20 before. And this did the trick! I went back to using special characters, and these also worked fine, as long as the password was “short”.

This seems to be a bug in Thunderbird – further research has led me to this forum entry: https://windowslivehelp.com/thread.aspx?threadid=1cc813b6-6b5c-4aba-a560-e4a89c4deea1

[Addition on 21-DEC-10]:

I think the analysis under the above link is wrong, this is not a bug in Thunderbird: I had the same problem with K-9 Mail on my Android phone. So my guess is that the root cause is on the MS side (now, how would have expected that? Really?), but who cares as long as you know how to avoid it.

12/07/2010

Die Bahn und der Konjunktiv

Falsch: “Der Regionalexpress XXX nach YYY, Abfahrt um 7:30, erhält 20 Minuten Verspätung”

Richtig: “Der Regionalexpress XXX nach YYY, dessen Abfahrt um 7:30 gewesen wäre, erhält 20 Minuten Verspätung”

Überkorrekt: “Der Regionalexpress XXX nach YYY, dessen Abfahrt laut Fahrplan (aber selten im wirklichen Leben) um 7:30 gewesen wäre, erhält 20 Minuten Verspätung”

12/03/2010

Converting Videos for the HTC Wildfire

I had thought it would be easier, but it actually took me half a day to figure out how to convert videos so they would play on my Wildfire! I compared codecs, resolution, frame rate of videos that would and would not play on it and sometimes there was no apparent difference – other than that one would play and the other would not!

I tried using FormatFactory but to no avail, even after having tested all kinds of settings.

I then tested “Videora Android Converter”, which did its job, but it is loaded with ads, so I wanted to avoid it.

Finally I tried Handbrake – successfully. You can just use the iPod preset and make sure you uncheck “iPod 5G support”.

So for those out there still researching: you don’t need to purchase any software, just get Handbrake (free) and use the above configuration.

11/20/2010

HTC Sync

HTC have developed a synchronization software for their Android models, named HTC Sync. I, as many others, had problems getting the software to run, or, more specifically, the computer to recognize the device. I had installed all the drivers, but the mobile phone and my computer would just not recognize each other.

In a forum I found the hint to enable USB Debugging on my phone, and, as unbelievable as it sounds, it really did the trick! Once I enabled USB debugging, my computer recognized the device, installed the drivers and was ready to sync. And even better, for future syncs I did not have to enable USB Debugging any more.

Apparently this is also known to HTC tech support as I saw in the document that their support provided me with.

But alas, now that I got the sync to work, more problems came up:

Contact sync would not recognize Outlook folders, it would always sync the top-level contact folder and nothing else.

Recurring appointments that were created during DST are one our off when DST is not effective, and I guess it will be the other way around as well.

So in the end, even though you can get HTC Sync to work, you are probably better off using Google contacts and calendar. If you absolutely need to sync your Outlook – well, tough S**t.

So, bottom line, great device, but sync software sucks!

10/26/2010

Was so alles an den Bahngleisen herumliegt …

IMG00002

Am besten einfach nicht darüber nachdenken, ob das an meinem Zug fehlen könnte …

10/21/2010

Save your Settings.settings to a Known Location

By default, when you call Save() on your settings, the LocalFileSettingsProvider (the only provider that .NET supplies) stores the settings in a path that is version-dependent.

This means that when you deploy a new version of your application, the path will change and the previous settings will be lost. Not entirely lost, of course, the LocalFileSettingsProvider has a method to “migrate” the old settings: Upgrade(), and this may exactly the way you want things to work, especially when you change the structure of your settings from one version to the next.

Where this begins to get annoying is when you write add-in for other application, in my case an Outlook add-in: here the provider uses the version of Outlook as part of the path to the user.config file; this means that when you get an update of the hosting application and it's version number changes, you loose your settings!

The only way I found to work around this was to implement my own settings provider, which is fairly simple. Once you have the class created (all it needs to do is inherit from System.Configuration.SettingsProvider) you can specify it as the provider for any setting you define in you application: select the setting and enter the fully qualified class name as the Provider in the Properties window.

I found the following information helpful to build my own settings provider:

http://www.codeproject.com/KB/vb/CustomSettingsProvider.aspx
http://msdn.microsoft.com/en-us/library/ms230624%28VS.90%29.aspx

To get you started writing your own settings provider here’s the code that I use, which is based on the articles mentioned above:

using System;



using System.Collections.Generic;



using System.Linq;



using System.Text;



 



using System.Configuration;



using System.Collections;



using System.IO;



using System.Xml;



using System.Collections.Specialized;



using log4net;



 



namespace MyNamespace



{



    class MySettingsProvider : SettingsProvider



    {



        #region Logging



        // log4net



        private static readonly ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);



        #endregion



 



        /// <summary>



        /// Constructor



        /// </summary>



        public MySettingsProvider()



        {



        }



 



        /// <summary>



        /// We use the product name (AssemblyProduct from AssemblyInfo.cs)



        /// as the application name



        /// </summary>



        public override string ApplicationName



        {



            get



            {



                string assemblyFileName = System.Reflection.Assembly.GetExecutingAssembly().Location;



                System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assemblyFileName);



                return fvi.ProductName;



            }



            set { }



        }



 



        /// <summary>



        /// Creates the path to the settings file, which is be design not version dependant



        /// (in contrast to the default provider).



        /// The path is built as user's application data directory, then a subdirectory based



        /// on the application name, and the file name is always user.config similar to the



        /// default provider.



        /// </summary>



        private string GetSavingPath



        {



            get



            {



                string retVal = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + 



                    ApplicationName + Path.DirectorySeparatorChar + "user.config";



                return retVal;



            }



        }



 



        /// <summary>



        /// Here we just call the base class initializer



        /// </summary>



        /// <param name="name"></param>



        /// <param name="col"></param>



        public override void Initialize(string name, NameValueCollection col)



        {



            base.Initialize(this.ApplicationName, col);



        }



 



        /// <summary>



        /// SetPropertyValue is invoked when ApplicationSettingsBase.Save is called



        /// ASB makes sure to pass each provider only the values marked for that provider -



        /// You need to manually set the provider for each setting.



        /// </summary>



        /// <param name="context"></param>



        /// <param name="propvals"></param>



        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection propvals)



        {



            string dir = Path.GetDirectoryName(GetSavingPath);



            if (!Directory.Exists(dir))



            {



                Log.Info("Settings directory does not exist, creating it");



                try



                {



                    Directory.CreateDirectory(dir);



                }



                catch (Exception fe)



                {



                    Log.ErrorFormat("Failed to create directory {0}", dir);



                    Log.Error("Exception", fe);



                }



            }



            try



            {



                using (XmlTextWriter tw = new XmlTextWriter(this.GetSavingPath, Encoding.Unicode))



                {



                    tw.WriteStartDocument();



                    tw.WriteStartElement(ApplicationName);



 



                    foreach (SettingsPropertyValue propertyValue in propvals)



                    {



                        if (IsUserScoped(propertyValue.Property) && propertyValue.SerializedValue != null)



                        {



                            tw.WriteStartElement(propertyValue.Name);



                            tw.WriteValue(propertyValue.SerializedValue);



                            tw.WriteEndElement();



                        }



                    }



 



                    tw.WriteEndElement();



                    tw.WriteEndDocument();



                }



            }



            catch (Exception e)



            {



                Log.Error("Unable to save settings", e);



            }



        }



 



        /// <summary>



        /// First instantiates all settings with their default values, then tries to



        /// retrieve the values from the settigs file. If the latter fails, the



        /// default values are returned.



        /// </summary>



        /// <param name="context"></param>



        /// <param name="props"></param>



        /// <returns></returns>



        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props)



        {



            // Create new collection of values



            SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();



 



            // Iterate through the settings to be retrieved (use their default values)



            foreach (SettingsProperty setting in props)



            {



                SettingsPropertyValue value = new SettingsPropertyValue(setting);



                value.IsDirty = false;



                /*value.SerializedValue = setting.DefaultValue;



                value.PropertyValue = setting.DefaultValue;*/



                values.Add(value);



            }



 



            if (!File.Exists(this.GetSavingPath))



            {



                Log.Debug("Settings file does not exist (yet) - returning default values");



                return values;



            }



 



            try



            {



                using (XmlTextReader tr = new XmlTextReader(this.GetSavingPath))



                {



                    try



                    {



                        tr.ReadStartElement(ApplicationName);



                        foreach (SettingsPropertyValue value in values)



                        {



                            if (IsUserScoped(value.Property))



                            {



                                try



                                {



                                    tr.ReadStartElement(value.Name);



                                    value.SerializedValue = tr.ReadContentAsObject();



                                    value.Deserialized = false;



                                    tr.ReadEndElement();



                                }



                                catch (XmlException xe1)



                                {



                                    Log.Error("Failed to read value from settings file", xe1);



                                }



                            }



                        }



                        tr.ReadEndElement();



                    }



                    catch (XmlException xe2)



                    {



                        Log.Error("Failed to read section from settings file", xe2);



                    }



                }



            }



            catch (Exception e)



            {



                Log.Error("Failed to read settings file", e);



            }



 



            return values;



        }



 



        // Helper method: walks the "attribute bag" for a given property



        // to determine if it is user-scoped or not.



        // Note that this provider does not enforce other rules, such as



        //   - unknown attributes



        //   - improper attribute combinations (e.g. both user and app - this implementation



        //     would say true for user-scoped regardless of existence of app-scoped)



        private bool IsUserScoped(SettingsProperty prop)



        {



            foreach (DictionaryEntry d in prop.Attributes)



            {



                Attribute a = (Attribute)d.Value;



                if (a.GetType() == typeof(UserScopedSettingAttribute))



                    return true;



            }



            return false;



        }



 



    }



}


adaxas Web Directory