Changing the exchange account to synchronize an Xda neo with

by Christoph Herold 29. Januar 2007 15:36

Today, I got a new Exchange account to replace my existing one. After copying everything, I only had to get my Xda neo to sync with the new account. This did not prove to be that easy, as simply changing the configured account led to interesting errors. Not only would ActiveSync always give me an error, it also produced errors in my PIM's contact list. It would show all contacts for a split second, then only show about half of the contacts. I tried to remove them all, but was only able to remove those shown. The others remained and broke the synchronization process.

So, how do you solve this, you ask. I don't know, if this is the best way, but it was the only one I found and that solved my problems without having to hard-reset my device:

  • Rename the file 'pim' to anything else and restart your PIM. This will clear all contacts, calendar entries, tasks, etc. If you don't sync all these items, you should probably make a backup first!
  • Remove the mobile device from the ActiveSync connections
  • Create a new connection to the PIM and start syncing with the new settings
  • I realize, this is not very comfortable, but at least it works and leaves the rest of your device intact (i.e. installed programs, customized sounds, etc.).

Tags: , ,



by Christoph Herold 21. Dezember 2006 11:34

While I was building an ASP.NET user control, I ran across the problem, how to serialize a property as the inner text of the Control in the ASPX-Code. I found a nice attribute named PersistenceModeAttribute, that allows you to specify, how a property is supposed to be persisted. Setting it to InnerDefaultProperty or EncodedInnerDefaultProperty should do the trick, I thought.

But, as I had to find out, this is only part of what needs to be done. There are two more Attributes, that control the parsing of a control: ParseChildrenAttribute and PersistChildrenAttribute. When you use InnerDefaultProperty to persist a property, you must add [ParseChildren(true, "")] and [PersistChildren(false)] to your control's class declaration. Otherwise things won't persist.

It took me a while to find this solution, and I found a nice explanation of things here:

Alvin did a really nice job of explaining, what the attributes do. So if you want the details, just visit his blog.

Tags: , ,



by Christoph Herold 27. November 2006 11:28

For the time being, I have built myself a helper class, that tries to fix the "timeout-bug" when using TransactionScope. And since I'm such a nice guy, I decided to let everyone have it ;-)

So here goes, completely commented including a usage example:

using System;
using System.Threading;
using System.Transactions;

namespace HeroldIT.Framework.Utils
    /// <summary>
    /// This class is used to abort transactions when the timeout occurs.
    /// </summary>
    /// <remarks>
    /// <para>This class is required, because TransactionScopes do not abort processing, when they expire. Instead
    /// all actions done after the timeout occurs are not included in the transaction, but instead carried out
    /// normally. This can lead to inconsistencies in your data, when processing large amounts.</para>
    /// <para>This class can be used nestedly, i.e. methods called in the supplied working delegate can safely
    /// create instances of this class.</para>
    /// </remarks>
    /// <example><code>
    /// try
    /// {
    ///     using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 0, 2)))
    ///     {
    ///         new TransactionHelper(delegate() {
    ///                 // do transactive work here
    ///             });
    ///         ts.Complete();
    ///     }
    /// }
    /// catch (TransactionAbortedException tae)
    /// {
    ///     // handle aborted transaction
    /// }
    /// </code>
    /// </example>
    public sealed class TransactionHelper
        /// <summary>
        /// A tagging object to determine, whether the thread is aborted due to a transaction timeout
        /// </summary>
        private object _abortObject;
        /// <summary>
        /// The current thread executing the transactive work
        /// </summary>
        private Thread _currentThread;

        /// <summary>
        /// Creates a new TransactionHelper that executes transactive statements and aborts the process
        /// if a timeout occurs.
        /// </summary>
        /// <param name="toExecute">The delegate to call for processing</param>
        public TransactionHelper(ThreadStart toExecute)
            if (null == toExecute)
                throw new ArgumentNullException("toExecute");
            // get current transaction
            Transaction tx = Transaction.Current;

            if (null == tx)
                throw new InvalidOperationException(Resources.ExcNoAmbientTransaction);

            // Don't execute, if the transaction is already aborted
            if (tx.TransactionInformation.Status != TransactionStatus.Aborted)
                // keep handle to current thread for aborting
                _currentThread = Thread.CurrentThread;

                // register completion handler
                tx.TransactionCompleted += new TransactionCompletedEventHandler(Current_TransactionCompleted);
                // execute transactive code
                catch (ThreadAbortException tae)
                    // was the thread aborted by our TransactionCompleted handler?
                    if (null != _abortObject && tae.ExceptionState == _abortObject)
                // unregister completion handler (required when using multiple TxHelpers in one transaction,
                // otherwise multiple ThreadAbortExceptions are thrown on timeout)
                tx.TransactionCompleted -= new TransactionCompletedEventHandler(Current_TransactionCompleted);

        /// <summary>
        /// Transaction completion event handler, that checks, whether a timeout occured
        /// and, if so, causes the registered executing thread to abort
        /// </summary>
        /// <param name="sender">The originating transaction</param>
        /// <param name="e">The event args for this event</param>
        void Current_TransactionCompleted(object sender, TransactionEventArgs e)
            // Is the transaction aborted (possibly due to timeout)?
            if (e.Transaction.TransactionInformation.Status == TransactionStatus.Aborted)
                // Is the executing thread registered?
                if (null != _currentThread)
                    // generate a new abortion tagging object
                    _abortObject = new object();
                    // abort the executing thread

I hope, this helps some of you. Of course, I'll be updating my blog, as soon as some notice of how TransactionScope is supposed to be used reaches me. I know, that ThreadAbortExceptions aren't something to use lightly, but currently I see no other way.

Tags: ,


Installing multiple versions of IE

by Christoph Herold 20. November 2006 11:12

One of the biggest pains for web developers is probably the fact, that Microsoft does not support installing multiple versions of IE in one Windows. But there is hope: The folks at tredosoft came up with a nice installer, that allows you to install most versions of IE. There are some small drawbacks, but it should suffice for most tests. You can get it here:



TransactionScope, ADO.NET, and Timeouts (revisited)

by Christoph Herold 18. November 2006 11:10

Someone has finally found a dirty, yet working solution to the TransactionScope problem. You can register an event on the transaction, that fires, when the transaction finishes, which also happens on a timeout. You can then abort the main thread, to keep further commands from executing.

%lt;p>And this is also the dirty part: ThreadAbortExceptions are a little dangerous and can cause unexpected behavior. But for now it works for me, and as long as Microsoft does not come up with a better solution, I'll have to use this.

You can find more details here:

Tags: ,


TransactionScope, ADO.NET, and Timeouts

by Christoph Herold 31. Oktober 2006 10:58

Happy Halloween everyone!

Today I'll tell you about some problems I've been having with the TransactionScope class. Namely, I've had timeouts running out, but the application still running the nested queries until they were finished. Amazingly, the data seemed to be in the tables, although the TimeoutException was thrown.

This has now happened to me in multiple applications. But today I read an article on the System.Transactions namespace ( There the author states, that you should open the database connection INSIDE the TransactionScope. This becomes logical, when you know that there is also a parameter you can add to the connection string named "auto-enlist" defaulting to true, that tells ADO.NET to look for an ambient transaction when connecting. So, if you open the database connection and then open a TransactionScope, the database does not seem to care about the ambient transaction.

I haven't tried yet, if this solves my problems. But since this is quite an important matter, I wonder why Microsoft does not point this out clearly. The TransactionScope may be a really great invention, but if you don't know how to use it, it causes damage instead of making things safer.

[Update]: This did not fix the problem. Instead, I built a test-app containing both a method, which first opens the database, then the TransactionScope, and a method doing it the other way around. Both methods have the same result. And that is VERY disappointing: The changes to the database made during the Transaction's non-timeout-ed period are rolled back, all changes AFTER the transaction times out are committed. I've written a post in the MSDN-Forum concerning Transactions Programming ( Let's see what they come up with.

Tags: ,


Service Factory with WCF

by Christoph Herold 24. September 2006 10:53

The Microsoft Patterns and Practices team published a Service Factory Add-On recently, that enables the Service Factory to also create WCF services. Sorrily, just after the release of the Add-On, the .NET Team released .NET 3.0 RC1, which is not supported by the Add-On.

If you still wish to install it, you can install the Orca tool located in the bin/ directory of the Windows Vista SDK, open the Service Factory WCF installer package, and change the value of the LaunchCondition variable FRAMEWORK30 to the Version of RC1 (3.0.04324.17). Save it and then you can install it.

You can find more information at

Tags: , , ,


Month List

Impressum (for the Germans)

Christoph Herold

Dieses Weblog wird bereitgestellt und verwaltet durch

Christoph Herold
Ignaz-Semmelweis-Str. 37
41540 Dormagen

Sie erreichen mich unter