Ejemplo n.º 1
0
        /// <summary>
        /// Initialises a new instance of the FieldLogExceptionItem class.
        /// </summary>
        /// <param name="priority">The priority of the new log item.</param>
        /// <param name="type">The scope type.</param>
        /// <param name="name">The scope name.</param>
        /// <param name="webRequestData">The web request data. This parameter is required for the WebRequestStart scope type.</param>
        public FieldLogScopeItem(FieldLogPriority priority, FieldLogScopeType type, string name, FieldLogWebRequestData webRequestData)
            : base(priority)
        {
            Type  = type;
            Level = FL.ScopeLevel;
            Name  = name;

            if (Type == FieldLogScopeType.ThreadStart)
            {
                IsBackgroundThread = Thread.CurrentThread.IsBackground;
                IsPoolThread       = Thread.CurrentThread.IsThreadPoolThread;

                Thread = Thread.CurrentThread;
            }
            if (Type == FieldLogScopeType.LogStart)
            {
                EnvironmentData = FieldLogEventEnvironment.Current();
                Size           += EnvironmentData.Size;
            }
            if (Type == FieldLogScopeType.WebRequestStart)
            {
                if (webRequestData == null)
                {
                    throw new ArgumentNullException("webRequestData", "The webRequestData parameter is required for the WebRequestStart scope type.");
                }
                WebRequestData = webRequestData;
                Size          += WebRequestData.Size;
            }

            Size += 4 + 4 +
                    (Name != null ? Name.Length * 2 : 0) +
                    4 + 4 + 4 + 4 + 4;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads the log item fields from the specified log file reader.
        /// </summary>
        /// <param name="reader">The log file reader to read from.</param>
        /// <param name="isRepeated">true if the log item is repeated from a previous file, false if it is written for the first time.</param>
        /// <returns>The read log item.</returns>
        internal static FieldLogScopeItem Read(FieldLogFileReader reader, bool isRepeated)
        {
            FieldLogScopeItem item = new FieldLogScopeItem();

            item.ReadBaseData(reader);
            item.IsRepeated = isRepeated;
            item.Type       = (FieldLogScopeType)reader.ReadByte();
            item.Level      = reader.ReadInt32();
            item.Name       = reader.ReadString();

            if (item.Type == FieldLogScopeType.ThreadStart)
            {
                byte flags = reader.ReadByte();
                item.IsBackgroundThread = (flags & 1) != 0;
                item.IsPoolThread       = (flags & 2) != 0;
            }
            if (item.Type == FieldLogScopeType.LogStart)
            {
                item.EnvironmentData = FieldLogEventEnvironment.Read(reader);
            }
            if (item.Type == FieldLogScopeType.WebRequestStart && reader.FormatVersion >= 2)
            {
                item.WebRequestData = FieldLogWebRequestData.Read(reader);
            }
            return(item);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialises a new instance of the FieldLogExceptionItem class.
        /// </summary>
        /// <param name="priority">The priority of the new log item.</param>
        /// <param name="ex">The exception instance.</param>
        /// <param name="context">The context in which the exception has been thrown. Can be an
        /// arbitrary string that is useful for the logging purpose.</param>
        /// <param name="customStackTrace">A StackTrace that shall be logged instead of the StackTrace from the Exception instance.</param>
        public FieldLogExceptionItem(FieldLogPriority priority, Exception ex, string context, StackTrace customStackTrace)
            : base(priority)
        {
            Exception = new FieldLogException(ex, customStackTrace);
            Context   = context;

            bool includeEnvironment = true;

            if (context == "AppDomain.FirstChanceException" ||
                context == FL.StackTraceOnlyExceptionContext)
            {
                // First-chance exception logging with environment may lead to crashes at WMI
                // requests, so it's disabled for now.
                // Testcase: Inspect FieldLogViewer with Snoop while debugging.
                includeEnvironment = false;
            }
            if (includeEnvironment)
            {
                EnvironmentData = FieldLogEventEnvironment.Current();
            }
            else
            {
                EnvironmentData = FieldLogEventEnvironment.Empty;
            }

            Size += Exception.Size +
                    (Context != null ? Context.Length * 2 : 0) +
                    EnvironmentData.Size;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads the log item fields from the specified log file reader.
        /// </summary>
        /// <param name="reader">The log file reader to read from.</param>
        /// <returns>The read log item.</returns>
        internal static FieldLogExceptionItem Read(FieldLogFileReader reader)
        {
            FieldLogExceptionItem item = new FieldLogExceptionItem();

            item.ReadBaseData(reader);
            item.Exception       = FieldLogException.Read(reader);
            item.Context         = reader.ReadString();
            item.EnvironmentData = FieldLogEventEnvironment.Read(reader);
            return(item);
        }
 /// <summary>
 /// Indicates whether the specified environment variable is null or an Empty environment.
 /// </summary>
 /// <param name="value">The variable to test.</param>
 /// <returns>true if the value parameter is null or an empty environment; otherwise, false.</returns>
 public static bool IsNullOrEmpty(FieldLogEventEnvironment value)
 {
     return(value == null || value == FieldLogEventEnvironment.Empty);
 }
        /// <summary>
        /// Reads the FieldLogEventEnvironment data from a log file reader.
        /// </summary>
        /// <param name="reader">Log file reader.</param>
        /// <returns>The environment data.</returns>
        internal static FieldLogEventEnvironment Read(FieldLogFileReader reader)
        {
            FieldLogEventEnvironment env = new FieldLogEventEnvironment();

            env.OSType             = (OSType)reader.ReadByte();
            env.OSVersion          = (OSVersion)reader.ReadByte();
            env.OSEdition          = (OSEdition)reader.ReadByte();
            env.OSServicePack      = reader.ReadString();
            env.OSBuild            = reader.ReadInt32();
            env.OSServicePackBuild = reader.ReadInt32();
            env.OSProductName      = reader.ReadString();
            env.OSLanguage         = reader.ReadString();
            env.OSLastBootTime     = new DateTime(reader.ReadInt64(), DateTimeKind.Utc);
            env.AppCompatLayer     = reader.ReadString();
            env.ClrType            = reader.ReadString();
            env.MouseButtons       = reader.ReadByte();
            env.MaxTouchPoints     = reader.ReadByte();
            env.ScreenDpi          = reader.ReadUInt16();

            env.CultureName          = reader.ReadString();
            env.CurrentDirectory     = reader.ReadString();
            env.EnvironmentVariables = reader.ReadString();
            env.CpuCount             = reader.ReadUInt16();
            env.HostName             = reader.ReadString();
            env.UserName             = reader.ReadString();
            env.ExecutablePath       = reader.ReadString();
            env.CommandLine          = reader.ReadString();
            env.AppVersion           = reader.ReadString();
            if (reader.FormatVersion >= 2)
            {
                env.AppAsmConfiguration = reader.ReadString();
            }
            env.ClrVersion                     = reader.ReadString();
            env.LocalTimeZoneOffset            = TimeSpan.FromMinutes(reader.ReadInt16());
            env.ProcessMemory                  = reader.ReadInt64();
            env.PeakProcessMemory              = reader.ReadInt64();
            env.TotalMemory                    = reader.ReadInt64();
            env.AvailableMemory                = reader.ReadInt64();
            env.ProcessId                      = reader.ReadInt32();
            env.PrimaryScreenWidth             = reader.ReadUInt16();
            env.PrimaryScreenHeight            = reader.ReadUInt16();
            env.PrimaryScreenBitsPerPixel      = reader.ReadByte();
            env.PrimaryScreenWorkingAreaLeft   = reader.ReadUInt16();
            env.PrimaryScreenWorkingAreaTop    = reader.ReadUInt16();
            env.PrimaryScreenWorkingAreaWidth  = reader.ReadUInt16();
            env.PrimaryScreenWorkingAreaHeight = reader.ReadUInt16();
            env.ScreenCount                    = reader.ReadByte();

            byte flags = reader.ReadByte();

            env.OSIs64Bit        = (flags & 1) != 0;
            env.OSIsAppServer    = (flags & 2) != 0;
            env.OSIsFailSafeBoot = (flags & 4) != 0;
            env.IsInteractive    = (flags & 8) != 0;
            env.IsProcess64Bit   = (flags & 16) != 0;
            env.IsAdministrator  = (flags & 32) != 0;

            // Check if the environment is actually empty
            if (env.CpuCount == 0)
            {
                return(FieldLogEventEnvironment.Empty);
            }

            return(env);
        }
        /// <summary>
        /// Returns a new instance of the FieldLogEventEnvironment class that contains information
        /// about the current environment and state of the system.
        /// </summary>
        /// <returns>The FieldLogEventEnvironment instance.</returns>
        public static FieldLogEventEnvironment Current()
        {
            FieldLogEventEnvironment env = new FieldLogEventEnvironment();

            env.OSType             = OSInfo.Type;
            env.OSVersion          = OSInfo.Version;
            env.OSEdition          = OSInfo.Edition;
            env.OSServicePack      = OSInfo.ServicePack;
            env.OSIs64Bit          = OSInfo.Is64Bit;
            env.OSBuild            = OSInfo.Build;
            env.OSServicePackBuild = OSInfo.ServicePackBuild;
            env.OSProductName      = OSInfo.ProductName;
            env.OSIsAppServer      = OSInfo.IsAppServer;
            env.OSLanguage         = OSInfo.Language;
            env.OSLastBootTime     = OSInfo.LastBootTime;
            env.OSIsFailSafeBoot   = OSInfo.IsFailSafeBoot;
            env.AppCompatLayer     = OSInfo.AppCompatLayer;
            env.ClrType            = OSInfo.ClrType;
            env.MouseButtons       = (byte)OSInfo.MouseButtons;
            env.MaxTouchPoints     = (byte)OSInfo.MaxTouchPoints;
            env.ScreenDpi          = (ushort)OSInfo.ScreenDpi;

            env.CultureName      = Thread.CurrentThread.CurrentCulture.Name;
            env.CurrentDirectory = Environment.CurrentDirectory;
            List <string> envNames = new List <string>();

            foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
            {
                envNames.Add(de.Key.ToString());
            }
            envNames.Sort(StringComparer.OrdinalIgnoreCase);
            StringBuilder envSb = new StringBuilder();

            foreach (string envName in envNames)
            {
                envSb.Append(envName);
                envSb.Append("=");
                envSb.Append(Environment.GetEnvironmentVariable(envName));
                envSb.Append("\n");
            }
            env.EnvironmentVariables = envSb.ToString().TrimEnd();
            env.CpuCount             = (ushort)Environment.ProcessorCount;
            env.HostName             = Environment.MachineName;
            env.UserName             = Environment.UserDomainName + "\\" + Environment.UserName;
            env.IsInteractive        = Environment.UserInteractive;
            env.ExecutablePath       = FL.EntryAssemblyLocation;
            env.CommandLine          = Environment.CommandLine;
            env.AppVersion           = FL.AppVersion;
            env.AppAsmConfiguration  = FL.AppAsmConfiguration;
            env.IsProcess64Bit       = IntPtr.Size == 8;         // .NET 4 only: Environment.Is64BitProcess
            env.ClrVersion           = Environment.Version.ToString();
#if NET20
            env.LocalTimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.UtcNow);
#else
            env.LocalTimeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);
#endif
            env.ProcessMemory                  = OSInfo.GetProcessPrivateMemory();
            env.PeakProcessMemory              = OSInfo.GetProcessPeakMemory();
            env.TotalMemory                    = OSInfo.GetTotalMemorySize();
            env.AvailableMemory                = OSInfo.GetAvailableMemorySize();
            env.ProcessId                      = System.Diagnostics.Process.GetCurrentProcess().Id;
            env.IsAdministrator                = OSInfo.IsCurrentUserLocalAdministrator();
            env.PrimaryScreenWidth             = (ushort)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            env.PrimaryScreenHeight            = (ushort)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
            env.PrimaryScreenBitsPerPixel      = (byte)System.Windows.Forms.Screen.PrimaryScreen.BitsPerPixel;
            env.PrimaryScreenWorkingAreaLeft   = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Left;
            env.PrimaryScreenWorkingAreaTop    = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Top;
            env.PrimaryScreenWorkingAreaWidth  = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            env.PrimaryScreenWorkingAreaHeight = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            env.ScreenCount                    = (byte)System.Windows.Forms.Screen.AllScreens.Length;

            // Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=682
            int ptrSize = IntPtr.Size;
            int strSize = ptrSize == 4 ? 20 : 32;

            env.Size = 4 + 4 + 4 + 4 +
                       ptrSize + (env.OSServicePack != null ? strSize + env.OSServicePack.Length * 2 : 0) +
                       4 + 4 + 4 +
                       ptrSize + (env.OSProductName != null ? strSize + env.OSProductName.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.OSLanguage != null ? strSize + env.OSLanguage.Length * 2 : 0) +
                       8 + 4 +
                       ptrSize + (env.AppCompatLayer != null ? strSize + env.AppCompatLayer.Length * 2 : 0) +
                       ptrSize + (env.ClrType != null ? strSize + env.ClrType.Length * 2 : 0) +
                       4 + 4 + 4 +
                       ptrSize + (env.CultureName != null ? strSize + env.CultureName.Length * 2 : 0) +
                       ptrSize + (env.CurrentDirectory != null ? strSize + env.CurrentDirectory.Length * 2 : 0) +
                       ptrSize + (env.EnvironmentVariables != null ? strSize + env.EnvironmentVariables.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.HostName != null ? strSize + env.HostName.Length * 2 : 0) +
                       ptrSize + (env.UserName != null ? strSize + env.UserName.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.ExecutablePath != null ? strSize + env.ExecutablePath.Length * 2 : 0) +
                       ptrSize + (env.CommandLine != null ? strSize + env.CommandLine.Length * 2 : 0) +
                       ptrSize + (env.AppVersion != null ? strSize + env.AppVersion.Length * 2 : 0) +
                       ptrSize + (env.AppAsmConfiguration != null ? strSize + env.AppAsmConfiguration.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.ClrVersion != null ? strSize + env.ClrVersion.Length * 2 : 0) +
                       8 + 8 + 8 + 8 + 8 +
                       4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
            return(env);
        }
        /// <summary>
        /// Reads the FieldLogEventEnvironment data from a log file reader.
        /// </summary>
        /// <param name="reader">Log file reader.</param>
        /// <returns>The environment data.</returns>
        internal static FieldLogEventEnvironment Read(FieldLogFileReader reader)
        {
            FieldLogEventEnvironment env = new FieldLogEventEnvironment();
            env.OSType = (OSType)reader.ReadByte();
            env.OSVersion = (OSVersion)reader.ReadByte();
            env.OSEdition = (OSEdition)reader.ReadByte();
            env.OSServicePack = reader.ReadString();
            env.OSBuild = reader.ReadInt32();
            env.OSServicePackBuild = reader.ReadInt32();
            env.OSProductName = reader.ReadString();
            env.OSLanguage = reader.ReadString();
            env.OSLastBootTime = new DateTime(reader.ReadInt64(), DateTimeKind.Utc);
            env.AppCompatLayer = reader.ReadString();
            env.ClrType = reader.ReadString();
            env.MouseButtons = reader.ReadByte();
            env.MaxTouchPoints = reader.ReadByte();
            env.ScreenDpi = reader.ReadUInt16();

            env.CultureName = reader.ReadString();
            env.CurrentDirectory = reader.ReadString();
            env.EnvironmentVariables = reader.ReadString();
            env.CpuCount = reader.ReadUInt16();
            env.HostName = reader.ReadString();
            env.UserName = reader.ReadString();
            env.ExecutablePath = reader.ReadString();
            env.CommandLine = reader.ReadString();
            env.AppVersion = reader.ReadString();
            if (reader.FormatVersion >= 2)
            {
                env.AppAsmConfiguration = reader.ReadString();
            }
            env.ClrVersion = reader.ReadString();
            env.LocalTimeZoneOffset = TimeSpan.FromMinutes(reader.ReadInt16());
            env.ProcessMemory = reader.ReadInt64();
            env.PeakProcessMemory = reader.ReadInt64();
            env.TotalMemory = reader.ReadInt64();
            env.AvailableMemory = reader.ReadInt64();
            env.ProcessId = reader.ReadInt32();
            env.PrimaryScreenWidth = reader.ReadUInt16();
            env.PrimaryScreenHeight = reader.ReadUInt16();
            env.PrimaryScreenBitsPerPixel = reader.ReadByte();
            env.PrimaryScreenWorkingAreaLeft = reader.ReadUInt16();
            env.PrimaryScreenWorkingAreaTop = reader.ReadUInt16();
            env.PrimaryScreenWorkingAreaWidth = reader.ReadUInt16();
            env.PrimaryScreenWorkingAreaHeight = reader.ReadUInt16();
            env.ScreenCount = reader.ReadByte();

            byte flags = reader.ReadByte();
            env.OSIs64Bit = (flags & 1) != 0;
            env.OSIsAppServer = (flags & 2) != 0;
            env.OSIsFailSafeBoot = (flags & 4) != 0;
            env.IsInteractive = (flags & 8) != 0;
            env.IsProcess64Bit = (flags & 16) != 0;
            env.IsAdministrator = (flags & 32) != 0;

            // Check if the environment is actually empty
            if (env.CpuCount == 0)
                return FieldLogEventEnvironment.Empty;

            return env;
        }
 /// <summary>
 /// Indicates whether the specified environment variable is null or an Empty environment.
 /// </summary>
 /// <param name="value">The variable to test.</param>
 /// <returns>true if the value parameter is null or an empty environment; otherwise, false.</returns>
 public static bool IsNullOrEmpty(FieldLogEventEnvironment value)
 {
     return value == null || value == FieldLogEventEnvironment.Empty;
 }
        /// <summary>
        /// Returns a new instance of the FieldLogEventEnvironment class that contains information
        /// about the current environment and state of the system.
        /// </summary>
        /// <returns>The FieldLogEventEnvironment instance.</returns>
        public static FieldLogEventEnvironment Current()
        {
            FieldLogEventEnvironment env = new FieldLogEventEnvironment();
            env.OSType = OSInfo.Type;
            env.OSVersion = OSInfo.Version;
            env.OSEdition = OSInfo.Edition;
            env.OSServicePack = OSInfo.ServicePack;
            env.OSIs64Bit = OSInfo.Is64Bit;
            env.OSBuild = OSInfo.Build;
            env.OSServicePackBuild = OSInfo.ServicePackBuild;
            env.OSProductName = OSInfo.ProductName;
            env.OSIsAppServer = OSInfo.IsAppServer;
            env.OSLanguage = OSInfo.Language;
            env.OSLastBootTime = OSInfo.LastBootTime;
            env.OSIsFailSafeBoot = OSInfo.IsFailSafeBoot;
            env.AppCompatLayer = OSInfo.AppCompatLayer;
            env.ClrType = OSInfo.ClrType;
            env.MouseButtons = (byte)OSInfo.MouseButtons;
            env.MaxTouchPoints = (byte)OSInfo.MaxTouchPoints;
            env.ScreenDpi = (ushort)OSInfo.ScreenDpi;

            env.CultureName = Thread.CurrentThread.CurrentCulture.Name;
            env.CurrentDirectory = Environment.CurrentDirectory;
            List<string> envNames = new List<string>();
            foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
            {
                envNames.Add(de.Key.ToString());
            }
            envNames.Sort(StringComparer.OrdinalIgnoreCase);
            StringBuilder envSb = new StringBuilder();
            foreach (string envName in envNames)
            {
                envSb.Append(envName);
                envSb.Append("=");
                envSb.Append(Environment.GetEnvironmentVariable(envName));
                envSb.Append("\n");
            }
            env.EnvironmentVariables = envSb.ToString().TrimEnd();
            env.CpuCount = (ushort)Environment.ProcessorCount;
            env.HostName = Environment.MachineName;
            env.UserName = Environment.UserDomainName + "\\" + Environment.UserName;
            env.IsInteractive = Environment.UserInteractive;
            env.ExecutablePath = FL.EntryAssemblyLocation;
            env.CommandLine = Environment.CommandLine;
            env.AppVersion = FL.AppVersion;
            env.AppAsmConfiguration = FL.AppAsmConfiguration;
            env.IsProcess64Bit = IntPtr.Size == 8;   // .NET 4 only: Environment.Is64BitProcess
            env.ClrVersion = Environment.Version.ToString();
            #if NET20
            env.LocalTimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.UtcNow);
            #else
            env.LocalTimeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);
            #endif
            env.ProcessMemory = OSInfo.GetProcessPrivateMemory();
            env.PeakProcessMemory = OSInfo.GetProcessPeakMemory();
            env.TotalMemory = OSInfo.GetTotalMemorySize();
            env.AvailableMemory = OSInfo.GetAvailableMemorySize();
            env.ProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;
            env.IsAdministrator = OSInfo.IsCurrentUserLocalAdministrator();
            env.PrimaryScreenWidth = (ushort)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            env.PrimaryScreenHeight = (ushort)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
            env.PrimaryScreenBitsPerPixel = (byte)System.Windows.Forms.Screen.PrimaryScreen.BitsPerPixel;
            env.PrimaryScreenWorkingAreaLeft = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Left;
            env.PrimaryScreenWorkingAreaTop = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Top;
            env.PrimaryScreenWorkingAreaWidth = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            env.PrimaryScreenWorkingAreaHeight = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            env.ScreenCount = (byte)System.Windows.Forms.Screen.AllScreens.Length;

            // Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=682
            int ptrSize = IntPtr.Size;
            int strSize = ptrSize == 4 ? 20 : 32;

            env.Size = 4 + 4 + 4 + 4 +
                ptrSize + (env.OSServicePack != null ? strSize + env.OSServicePack.Length * 2 : 0) +
                4 + 4 + 4 +
                ptrSize + (env.OSProductName != null ? strSize + env.OSProductName.Length * 2 : 0) +
                4 +
                ptrSize + (env.OSLanguage != null ? strSize + env.OSLanguage.Length * 2 : 0) +
                8 + 4 +
                ptrSize + (env.AppCompatLayer != null ? strSize + env.AppCompatLayer.Length * 2 : 0) +
                ptrSize + (env.ClrType != null ? strSize + env.ClrType.Length * 2 : 0) +
                4 + 4 + 4 +
                ptrSize + (env.CultureName != null ? strSize + env.CultureName.Length * 2 : 0) +
                ptrSize + (env.CurrentDirectory != null ? strSize + env.CurrentDirectory.Length * 2 : 0) +
                ptrSize + (env.EnvironmentVariables != null ? strSize + env.EnvironmentVariables.Length * 2 : 0) +
                4 +
                ptrSize + (env.HostName != null ? strSize + env.HostName.Length * 2 : 0) +
                ptrSize + (env.UserName != null ? strSize + env.UserName.Length * 2 : 0) +
                4 +
                ptrSize + (env.ExecutablePath != null ? strSize + env.ExecutablePath.Length * 2 : 0) +
                ptrSize + (env.CommandLine != null ? strSize + env.CommandLine.Length * 2 : 0) +
                ptrSize + (env.AppVersion != null ? strSize + env.AppVersion.Length * 2 : 0) +
                ptrSize + (env.AppAsmConfiguration != null ? strSize + env.AppAsmConfiguration.Length * 2 : 0) +
                4 +
                ptrSize + (env.ClrVersion != null ? strSize + env.ClrVersion.Length * 2 : 0) +
                8 + 8 + 8 + 8 + 8 +
                4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
            return env;
        }
 public FieldLogEnvironmentViewModel(FieldLogEventEnvironment environment, FieldLogItemViewModel itemVM)
 {
     this.Environment = environment;
     this.ItemVM = itemVM;
 }