private static string GetTitle(System.Exception ex)
        {
            var innerEx       = ExceptionRegistrator.GetMostInnerException(ex);
            var splittedTitle = innerEx.StackTrace.Split(
                new[] { " in " }, StringSplitOptions.RemoveEmptyEntries).First().Trim().Split(
                new[] { " at " }, StringSplitOptions.RemoveEmptyEntries);

            var title = GetFirstLine(splittedTitle).Trim().Split(
                new[] { "(" }, StringSplitOptions.RemoveEmptyEntries).First().Trim();

            title = innerEx.Message.Trim('.') + (title.Trim().StartsWith("at") ? " " : " at ") + title.Trim();
            title = TFSStringUtil.GenerateValidTFSStringType(title);
            return(title);
        }
        /// <summary>
        /// Create a new exception repoert item.
        /// </summary>
        /// <param name="applicationName"></param>
        /// <param name="reporter"></param>
        /// <param name="username"></param>
        /// <param name="ex"></param>
        /// <param name="version"></param>
        /// <param name="description">Step to reproduce the error.</param>
        public TFSExceptionReport(string applicationName, string reporter, string username, System.Exception ex, string version, string description)
        {
            //ensure contracts.
            Contract.Requires(String.IsNullOrEmpty(applicationName));
            Contract.Requires(String.IsNullOrEmpty(reporter));
            Contract.Requires(String.IsNullOrEmpty(username));
            Contract.Requires(ex != null);

            //ensure contracts.
            Contract.Ensures(ExceptionEntity != null);
            Contract.Ensures(String.IsNullOrEmpty(ExceptionEntity.ApplicationName));
            Contract.Ensures(String.IsNullOrEmpty(ExceptionEntity.Reporter));
            Contract.Ensures(String.IsNullOrEmpty(ExceptionEntity.Username));

            var stackTrace      = ExceptionRegistrator.CreateExceptionText(ex);
            var title           = GetTitle(ex);
            var message         = title;
            var exceptionClass  = GetExceptionClass(ex);
            var exceptionMethod = GetExceptionMethod(ex);

            ExceptionEntity = new ExceptionEntity
            {
                ApplicationName  = applicationName,
                Reporter         = reporter,
                Username         = username,
                Version          = version,
                ExceptionSource  = ex.Source ?? String.Empty,
                ExceptionClass   = exceptionClass,
                ExceptionMethod  = exceptionMethod,
                StackTrace       = stackTrace,
                Comment          = description,
                ExceptionMessage = message,
                ExceptionType    = ex.GetType().ToString(),
                ExceptionTitle   = title
            };
        }