Beispiel #1
0
        /// <summary>
        /// </summary>
        public static bool IsDeveloperRuntime()
        {
            var entryAssembly = Assembly.GetEntryAssembly();

            if (entryAssembly == null)
            {
                //Проверяем, что это не ASP.NET
                var stackTrace = new global::System.Diagnostics.StackTrace();

                if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "Microsoft.VisualStudio.Web.Host")
                {
                    return(true);
                }
                else
                {
                    var firstMethod = stackTrace.GetFrames().Last().GetMethod();
                    if (firstMethod.Name == "Initialize" && firstMethod.Module.Name.ToLower() == "system.web.dll")
                    {
                    }
                    else if (firstMethod.Name == "InitializeApplication" && firstMethod.Module.Name.ToLower() == "system.web.dll")
                    {
                    }
                    else
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        internal static bool IsDeveloperRuntime()
        {
            var entryAssembly = Assembly.GetEntryAssembly();

            if (entryAssembly == null)
            {
                //Проверяем, что это не ASP.NET
                var stackTrace = new global::System.Diagnostics.StackTrace();

                var firstMethod = stackTrace.GetFrames().Last().GetMethod();
                if (firstMethod.Name == "Initialize" && firstMethod.Module.Name.ToLower() == "system.web.dll")
                {
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }